From: Eileen McNaughton Date: Mon, 5 Jan 2015 02:34:20 +0000 (+1300) Subject: move declaraion of hook class into parent class for re-use X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6c466b511d5828a827bc8e6edcd7d94bb031f7af;p=civicrm-core.git move declaraion of hook class into parent class for re-use acl fix --- diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index ffa3495f8e..83535b1712 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -135,6 +135,23 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { */ private $tx = NULL; + /** + * @var CRM_Utils_Hook_UnitTests hookClass + * example of setting a method for a hook + * $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookAllResults')); + */ + public $hookClass = NULL; + + /** + * @var array common values to be re-used multiple times within a class - usually to create the relevant entity + */ + protected $_params = array(); + + /** + * @var CRM_Extension_System + */ + protected $origExtensionSystem; + /** * Constructor * @@ -353,7 +370,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $session = CRM_Core_Session::singleton(); $session->set('userID', NULL); - CRM_Utils_Hook::singleton(TRUE); $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // REVERT // Use a temporary file for STDIN $GLOBALS['stdin'] = tmpfile(); @@ -377,7 +393,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { // when running unit tests, use mockup user framework $config->setUserFramework('UnitTests'); - + $this->hookClass = CRM_Utils_Hook::singleton(TRUE); // also fix the fatal error handler to throw exceptions, // rather than exit $config->fatalErrorHandler = 'CiviUnitTestCase_fatalErrorHandler'; @@ -474,6 +490,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { */ protected function tearDown() { error_reporting(E_ALL & ~E_NOTICE); + CRM_Utils_Hook::singleton()->reset(); + $this->hookClass->reset(); $session = CRM_Core_Session::singleton(); $session->set('userID', NULL); @@ -960,13 +978,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * @param null $count * @throws Exception * @return array|int - * @internal param string $type - per http://php.net/manual/en/function.gettype.php possible types - * - boolean - * - integer - * - double - * - string - * - array - * - object */ public function callAPISuccessGetCount($entity, $params, $count = NULL) { $params += array( diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index 82978f90d3..3d22cc196a 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -36,16 +36,7 @@ require_once 'CiviTest/CiviUnitTestCase.php'; class api_v3_ACLPermissionTest extends CiviUnitTestCase { protected $_apiversion = 3; - protected $_params; - - /** - * @var CRM_Utils_Hook_UnitTests - */ - protected $hookClass = NULL; public $DBResetRequired = FALSE; - - - protected $_entity; public function setUp() { @@ -53,7 +44,6 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { $baoObj = new CRM_Core_DAO(); $baoObj->createTestObject('CRM_Pledge_BAO_Pledge', array(), 1, 0); $baoObj->createTestObject('CRM_Core_BAO_Phone', array(), 1, 0); - $this->hookClass = CRM_Utils_Hook::singleton(); $config = CRM_Core_Config::singleton(); $config->userPermissionClass->permissions = array(); }