X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviUnitTestCase.php;h=8e0109380aadb6264aa0084535e9a5a7656548d4;hb=91786f443a2a7bf636d83723404e6cf925b8064d;hp=1343cffa1b4297b55fe44511b9798e202bb41302;hpb=67755a31f744198c7fd8ae4f3be3cdf7e4d93a90;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 1343cffa1b..8e0109380a 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -334,12 +334,6 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { // disable any left-over test extensions CRM_Core_DAO::executeQuery('DELETE FROM civicrm_extension WHERE full_name LIKE "test.%"'); - $extensions = \CRM_Extension_System::singleton()->getManager(); - $api4Status = $extensions->getStatus('org.civicrm.api4'); - if ($api4Status != $extensions::STATUS_INSTALLED && $api4Status != $extensions::STATUS_UNKNOWN) { - $extensions->enable(['org.civicrm.api4']); - } - // reset all the caches CRM_Utils_System::flushCache(); @@ -365,6 +359,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { $_REQUEST = $_GET = $_POST = []; error_reporting(E_ALL); + $this->renameLabels(); $this->_sethtmlGlobals(); } @@ -457,6 +452,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ protected function tearDown() { $this->_apiversion = 3; + $this->resetLabels(); error_reporting(E_ALL & ~E_NOTICE); CRM_Utils_Hook::singleton()->reset(); @@ -1374,7 +1370,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { if (!isset($params['target_contact_id'])) { $params['target_contact_id'] = $this->individualCreate(array( 'first_name' => 'Julia', - 'Last_name' => 'Anderson', + 'last_name' => 'Anderson', 'prefix' => 'Ms.', 'email' => 'julia_anderson@civicrm.org', 'contact_type' => 'Individual', @@ -3326,4 +3322,24 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) return $csv; } + /** + * Rename various labels to not match the names. + * + * Doing these mimics the fact the name != the label in international installs & triggers failures in + * code that expects it to. + */ + protected function renameLabels() { + $replacements = ['Pending', 'Refunded']; + foreach ($replacements as $name) { + CRM_Core_DAO::executeQuery("UPDATE civicrm_option_value SET label = '{$name} Label**' where label = '{$name}' AND name = '{$name}'"); + } + } + + /** + * Undo any label renaming. + */ + protected function resetLabels() { + CRM_Core_DAO::executeQuery("UPDATE civicrm_option_value SET label = REPLACE(name, ' Label**', '') WHERE label LIKE '% Label**'"); + } + }