* <http://www.gnu.org/licenses/>.
*/
+use Civi\Api4\OptionGroup;
use Civi\Payment\System;
+use Civi\Api4\OptionValue;
use League\Csv\Reader;
/**
*
* This can be used to test hooks within tests. For example in the ACL_PermissionTrait:
*
- * $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookAllResults'));
+ * $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereHookAllResults']);
*
* @var \CRM_Utils_Hook_UnitTests
*/
- public $hookClass = NULL;
+ public $hookClass;
/**
* @var array
/**
* Create default domain contacts for the two domains added during test class.
* database population.
- */
- public function createDomainContacts() {
- $this->organizationCreate();
- $this->organizationCreate(['organization_name' => 'Second Domain']);
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \API_Exception
+ */
+ 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,
+ ],
+ ]);
+ OptionValue::replace(FALSE)->addWhere(
+ 'option_group_id:name', '=', 'from_email_address'
+ )->setDefaults([
+ 'is_default' => 1,
+ 'name' => '"FIXME" <info@EXAMPLE.ORG>',
+ 'label' => '"FIXME" <info@EXAMPLE.ORG>',
+ ])->setRecords([['domain_id' => 1], ['domain_id' => 2]])->execute();
}
/**
* 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();
}
/**
* CHeck that all tests that have created payments have created them with the right financial entities.
*
+ * @throws \API_Exception
* @throws \CRM_Core_Exception
*/
protected function assertPostConditions() {
+ // Reset to version 3 as not all (e.g payments) work on v4
+ $this->_apiversion = 3;
if ($this->isLocationTypesOnPostAssert) {
$this->assertLocationValidity();
}
+ $this->assertCount(1, OptionGroup::get(FALSE)
+ ->addWhere('name', '=', 'from_email_address')
+ ->execute());
if (!$this->isValidateFinancialsOnPostAssert) {
return;
}