From c3d574fcdef70362db4e7b28fa5006ae8e486f7e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 18 Jul 2015 17:08:34 +1200 Subject: [PATCH] enforce enotice compliance on remaining tests --- CRM/Extension/Container/Collection.php | 2 +- .../test.extension.manager.paymenttest/info.xml | 3 ++- .../test.extension.manager.paymenttest/main.php | 4 ++++ .../CRM/Extension/Container/CollectionTest.php | 4 ---- tests/phpunit/CRM/Extension/Manager/ModuleTest.php | 7 +++---- tests/phpunit/CRM/Extension/Manager/PaymentTest.php | 4 ---- tests/phpunit/CiviTest/CiviUnitTestCase.php | 13 ++----------- 7 files changed, 12 insertions(+), 25 deletions(-) diff --git a/CRM/Extension/Container/Collection.php b/CRM/Extension/Container/Collection.php index 41b1bbb911..07ce478dcd 100644 --- a/CRM/Extension/Container/Collection.php +++ b/CRM/Extension/Container/Collection.php @@ -155,7 +155,7 @@ class CRM_Extension_Container_Collection implements CRM_Extension_Container_Inte if ($this->cache) { $k2c = $this->cache->get($this->cacheKey); } - if (!is_array($k2c)) { + if (!isset($k2c) || !is_array($k2c)) { $k2c = array(); $containerNames = array_reverse(array_keys($this->containers)); foreach ($containerNames as $name) { diff --git a/tests/extensions/test.extension.manager.paymenttest/info.xml b/tests/extensions/test.extension.manager.paymenttest/info.xml index 2782446752..9e91db0e18 100644 --- a/tests/extensions/test.extension.manager.paymenttest/info.xml +++ b/tests/extensions/test.extension.manager.paymenttest/info.xml @@ -1,6 +1,7 @@ main test_extension_manager_paymenttest + Sample Payment extension username password @@ -18,4 +19,4 @@ 0 1 - \ No newline at end of file + diff --git a/tests/extensions/test.extension.manager.paymenttest/main.php b/tests/extensions/test.extension.manager.paymenttest/main.php index 98d817ac8e..e28abf9c70 100644 --- a/tests/extensions/test.extension.manager.paymenttest/main.php +++ b/tests/extensions/test.extension.manager.paymenttest/main.php @@ -8,18 +8,22 @@ class test_extension_manager_paymenttest extends CRM_Core_Payment { static $counts = array(); public function install() { + self::$counts['install'] = isset(self::$counts['install']) ? self::$counts['install'] : 0; self::$counts['install'] = 1 + (int) self::$counts['install']; } public function uninstall() { + self::$counts['uninstall'] = isset(self::$counts['uninstall']) ? self::$counts['uninstall'] : 0; self::$counts['uninstall'] = 1 + (int) self::$counts['uninstall']; } public function disable() { + self::$counts['disable'] = isset(self::$counts['disable']) ? self::$counts['disable'] : 0; self::$counts['disable'] = 1 + (int) self::$counts['disable']; } public function enable() { + self::$counts['enable'] = isset(self::$counts['enable']) ? self::$counts['enable'] : 0; self::$counts['enable'] = 1 + (int) self::$counts['enable']; } diff --git a/tests/phpunit/CRM/Extension/Container/CollectionTest.php b/tests/phpunit/CRM/Extension/Container/CollectionTest.php index 4952a8dc1c..691514c6d7 100644 --- a/tests/phpunit/CRM/Extension/Container/CollectionTest.php +++ b/tests/phpunit/CRM/Extension/Container/CollectionTest.php @@ -30,10 +30,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * Class CRM_Extension_Container_CollectionTest */ class CRM_Extension_Container_CollectionTest extends CiviUnitTestCase { - //@todo make BAO enotice compliant & remove the line below - // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE - // new test classes should be compliant. - public $_eNoticeCompliant = FALSE; public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php index 4d91b058be..c8341b9be0 100644 --- a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php @@ -6,10 +6,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * Class CRM_Extension_Manager_ModuleTest */ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { - //@todo make BAO enotice compliant & remove the line below - // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE - // new test classes should be compliant. - public $_eNoticeCompliant = FALSE; public function setUp() { parent::setUp(); @@ -283,6 +279,9 @@ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { */ public static function incHookCount($module, $name) { global $_test_extension_manager_moduletest_counts; + if (!isset($_test_extension_manager_moduletest_counts[$module][$name])) { + $_test_extension_manager_moduletest_counts[$module][$name] = 0; + } $_test_extension_manager_moduletest_counts[$module][$name] = 1 + (int) $_test_extension_manager_moduletest_counts[$module][$name]; } diff --git a/tests/phpunit/CRM/Extension/Manager/PaymentTest.php b/tests/phpunit/CRM/Extension/Manager/PaymentTest.php index acfeaad944..eb65b99feb 100644 --- a/tests/phpunit/CRM/Extension/Manager/PaymentTest.php +++ b/tests/phpunit/CRM/Extension/Manager/PaymentTest.php @@ -30,10 +30,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * Class CRM_Extension_Manager_PaymentTest */ class CRM_Extension_Manager_PaymentTest extends CiviUnitTestCase { - //@todo make BAO enotice compliant & remove the line below - // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE - // new test classes should be compliant. - public $_eNoticeCompliant = FALSE; public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index fb3e4aa72f..a8a830ad48 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -118,11 +118,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { */ public static $populateOnce = FALSE; - /** - * Allow classes to state E-notice compliance - */ - public $_eNoticeCompliant = TRUE; - /** * @var boolean DBResetRequired allows skipping DB reset * in specific test case. If you still need @@ -433,12 +428,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { //flush component settings CRM_Core_Component::getEnabledComponents(TRUE); - if ($this->_eNoticeCompliant) { - error_reporting(E_ALL); - } - else { - error_reporting(E_ALL & ~E_NOTICE); - } + error_reporting(E_ALL); + $this->_sethtmlGlobals(); } -- 2.25.1