This fixes a situation where the domain contact may not have an email (or exist) if this
test is run in combination with certain others. The last test in the suite relies on the
domain contact having an email. This test was not following the practice
of having a tearDown but the tearDown was also flawed in recreating the domain
contacts but not their emails
[
// The next day, send an email.
'time' => date('Y-m-d H:i:s', strtotime($contact['values'][$contact['id']]['created_date'] . ' +1 day')),
- 'recipients' => [['test-birth_day@example.com']],
+ 'recipients' => [['test-birth_day@example.com'], ['fixme.domainemail@example.org'], ['domainemail2@example.org']],
],
]);
}
[
// On the eve of 3 years after they were modified, send an email.
'time' => date('Y-m-d H:i:s', strtotime($modifiedDate . ' +3 years -1 day')),
- 'recipients' => [['test-birth_day@example.com']],
+ 'recipients' => [['test-birth_day@example.com'], ['fixme.domainemail@example.org'], ['domainemail2@example.org']],
],
]);
}
/**
* Create default domain contacts for the two domains added during test class.
* database population.
+ *
+ * @throws \CiviCRM_API3_Exception
*/
- public function createDomainContacts() {
- $this->organizationCreate();
- $this->organizationCreate(['organization_name' => 'Second Domain']);
+ public function createDomainContacts(): void {
+ $this->organizationCreate(['api.Email.create' => ['email' => 'fixme.domainemail@example.org']]);
+ $this->organizationCreate([
+ 'organization_name' => 'Second Domain',
+ 'api.Email.create' => ['email' => 'domainemail2@example.org'],
+ 'api.Address.create' => [
+ 'street_address' => '15 Main St',
+ 'location_type_id' => 1,
+ 'city' => 'Collinsville',
+ 'country_id' => 1228,
+ 'state_province_id' => 1003,
+ 'postal_code' => 6022,
+ ],
+ ]);
}
/**
* Common teardown functions for all unit tests.
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
protected function tearDown(): void {
$this->_apiversion = 3;
CRM_Core_Transaction::forceRollbackIfEnabled();
\Civi\Core\Transaction\Manager::singleton(TRUE);
- $tablesToTruncate = ['civicrm_contact', 'civicrm_uf_match'];
+ $tablesToTruncate = ['civicrm_contact', 'civicrm_uf_match', 'civicrm_email', 'civicrm_address'];
$this->quickCleanup($tablesToTruncate);
$this->createDomainContacts();
}
'Bob, Bob :: bob@bob.com',
'C Bobby, Bobby',
'H Bobby, Bobby :: bob@h.com',
- 'Second Domain',
+ 'Second Domain :: domainemail2@example.org',
$this->callAPISuccessGetValue('Contact', ['id' => $loggedInContactID, 'return' => 'last_name']) . ', Logged In :: anthony_anderson@civicrm.org',
];
$this->assertEquals(6, $result['count']);
'A Bobby, Bobby :: bob@bobby.com',
'Bob, Bob :: bob@bob.com',
'C Bobby, Bobby',
- 'Second Domain',
+ 'Second Domain :: domainemail2@example.org',
$this->callAPISuccessGetValue('Contact', ['id' => $loggedInContactID, 'return' => 'last_name']) . ', Logged In :: anthony_anderson@civicrm.org',
];
foreach ($expectedData as $index => $value) {
* Clean up after each test.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
}
}
$this->restoreUFGroupOne();
+ parent::tearDown();
}
/**
/**
* Test get function with current domain.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function testGetCurrentDomain() {
+ public function testGetCurrentDomain(): void {
$params = ['current_domain' => 1];
$result = $this->callAPISuccess('domain', 'get', $params);
public $DBResetRequired = FALSE;
+ /**
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
+ */
public function setUp(): void {
parent::setUp();
- $this->useTransaction(TRUE);
+ $this->useTransaction();
- $entityParams = ['contact_id' => 1];
+ $entityParams = ['contact_id' => $this->individualCreate()];
$this->_entity = 'EntityBatch';
$this->_entityID = $this->contributionCreate($entityParams);