X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCRM%2FCore%2FBAO%2FSettingTest.php;h=34cf4a8f47d7e286eb3c4aa6c3ed6db4bc740286;hb=bb761f09f85629fc7385aea8755a8459b8108878;hp=2901412599e2514b53dd836f124b86caf7218821;hpb=17a4aeb2f74f7d78da6a7c55bb26b0c2b703f677;p=civicrm-core.git diff --git a/tests/phpunit/CRM/Core/BAO/SettingTest.php b/tests/phpunit/CRM/Core/BAO/SettingTest.php index 2901412599..34cf4a8f47 100644 --- a/tests/phpunit/CRM/Core/BAO/SettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/SettingTest.php @@ -15,17 +15,29 @@ */ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase { + /** + * Original value of civicrm_setting global. + * @var array + */ + private $origSetting; + public function setUp() { parent::setUp(); global $civicrm_setting; $this->origSetting = $civicrm_setting; - CRM_Utils_Cache::singleton()->flush(); + CRM_Utils_Cache::singleton()->clear(); } + /** + * Clean up after test. + * + * @throws \CRM_Core_Exception + */ public function tearDown() { global $civicrm_setting; $civicrm_setting = $this->origSetting; - CRM_Utils_Cache::singleton()->flush(); + $this->quickCleanup(['civicrm_contribution']); + CRM_Utils_Cache::singleton()->clear(); parent::tearDown(); } @@ -79,6 +91,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase { 'notes' => '

Give me money

', 'tax_term' => 'Extortion', 'tax_display_settings' => 'Exclusive', + // NOTE: This form of `invoicing` is accepted, but it may be normalized to the idiomatic form with a nested array. 'invoicing' => 1, 'is_email_pdf' => '1', ]; @@ -88,7 +101,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase { $getVersion = $this->callAPISuccessGetValue('Setting', ['name' => 'contribution_invoice_settings']); $this->assertEquals($settingsFromAPI, $settingsFromGet); $this->assertAPIArrayComparison($getVersion, $settingsFromGet); - $this->assertEquals($contributionSettings, $settingsFromGet); + $this->assertEquals(['invoicing' => ['invoicing' => 1]] + $contributionSettings, $settingsFromGet); // These are the preferred retrieval methods. $this->assertEquals('G_', Civi::settings()->get('invoice_prefix')); @@ -227,4 +240,13 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase { $this->assertEquals('Development', $environment); } + /** + * Test that options defined as a pseudoconstant can be converted to options. + */ + public function testPseudoConstants() { + $this->contributionPageCreate(); + $metadata = \Civi\Core\SettingsMetadata::getMetadata(['name' => ['default_invoice_page']], NULL, TRUE); + $this->assertEquals('Test Contribution Page', $metadata['default_invoice_page']['options'][1]); + } + }