From ecda7f33f283066d56d2824671f3c6b43589a488 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 29 Apr 2020 18:23:40 -0700 Subject: [PATCH] testHandlingOfContributionInvoiceSetting() - More realistic data+assertion In practice, for the old setting `contribution_invoice_settings`, the `invoicing` property could take one of two values: 1. If enabled, the value is an array with trueish subkey: `['invoicing'=>['invoicing'=>1]]` 2. If disabled, the value is a numeric `0`: `['invoicing'=>0]` Following this means better compatibility. The format is counter-intuitive, and the unit-test sets the value to enabled using a more intuitive format (`['invoicing'=>1]`). It's currently valid to `set()` this way, but `get()`ting the value produces the more-compatible/historical format. --- tests/phpunit/CRM/Core/BAO/SettingTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/CRM/Core/BAO/SettingTest.php b/tests/phpunit/CRM/Core/BAO/SettingTest.php index 2901412599..d4c4ddebb1 100644 --- a/tests/phpunit/CRM/Core/BAO/SettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/SettingTest.php @@ -79,6 +79,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 +89,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')); -- 2.25.1