X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviUnitTestCase.php;h=10fb69f97694da28bb044e9625bcc91ec4c0a084;hb=c0a1f187861eb5765c99252dff6148956135c71b;hp=a803e0212d9523a8904e78bac01ee84b5eb54d02;hpb=c3a3074fd6c012f52f9fbbfeeac8a34c40b152d8;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index a803e0212d..10fb69f976 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 @@ -401,19 +396,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { // "initialize" CiviCRM to avoid problems when running single tests // FIXME: look at it closer in second stage - // initialize the object once db is loaded - CRM_Core_Config::$_mail = NULL; - $config = CRM_Core_Config::singleton(); - - // 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'; - - // enable backtrace to get meaningful errors - $config->backtrace = 1; + $GLOBALS['civicrm_setting']['domain']['fatalErrorHandler'] = 'CiviUnitTestCase_fatalErrorHandler'; + $GLOBALS['civicrm_setting']['domain']['backtrace'] = 1; // disable any left-over test extensions CRM_Core_DAO::executeQuery('DELETE FROM civicrm_extension WHERE full_name LIKE "test.%"'); @@ -421,24 +405,27 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { // reset all the caches CRM_Utils_System::flushCache(); + // initialize the object once db is loaded + \Civi::reset(); + $config = CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance + + // when running unit tests, use mockup user framework + $config->setUserFramework('UnitTests'); + $this->hookClass = CRM_Utils_Hook::singleton(TRUE); + // Make sure the DB connection is setup properly $config->userSystem->setMySQLTimeZone(); $env = new CRM_Utils_Check_Env(); CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime()); // clear permissions stub to not check permissions - $config = CRM_Core_Config::singleton(); $config->userPermissionClass->permissions = NULL; //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(); } @@ -1464,7 +1451,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { 'billing_mode' => 1, ), $params); - $result = $this->callAPISuccess('payment_processor', 'create', $params); + $result = $this->callAPISuccess('PaymentProcessor', 'create', $params); return $result['id']; } @@ -1503,7 +1490,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * Create Payment Processor. * * @return CRM_Financial_DAO_PaymentProcessor - * instance of Payment Processsor + * instance of Payment Processor */ public function processorCreate() { $processorParams = array( @@ -1518,8 +1505,20 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { 'url_recur' => 'http://dummy.com', 'billing_mode' => 1, ); - $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($processorParams); - return $paymentProcessor; + return CRM_Financial_BAO_PaymentProcessor::create($processorParams); + } + + /** + * Create Payment Processor. + * + * @param array $processorParams + * + * @return \CRM_Core_Payment_Dummy + * Instance of Dummy Payment Processor + */ + public function dummyProcessorCreate($processorParams = array()) { + $paymentProcessor = $this->processorCreate($processorParams); + return Civi\Payment\System::singleton()->getById($paymentProcessor->id); } /** @@ -1827,7 +1826,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { 'is_primary' => 1, 'name' => 'Saint Helier St', 'county' => 'Marin', - 'country' => 'United States', + 'country' => 'UNITED STATES', 'state_province' => 'Michigan', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', @@ -3055,7 +3054,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * $this->_permissionedDisabledGroup = $this->groupCreate(array('title' => 'pick-me-disabled', 'is_active' => 0, 'name' => 'pick-me-disabled')); * $this->_permissionedGroup = $this->groupCreate(array('title' => 'pick-me-active', 'is_active' => 1, 'name' => 'pick-me-active')); */ - public function setupACL() { + public function setupACL($isProfile = FALSE) { global $_REQUEST; $_REQUEST = $this->_params; @@ -3077,36 +3076,52 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) CRM_Core_DAO::executeQuery(" INSERT INTO civicrm_acl_entity_role ( - `acl_role_id`, `entity_table`, `entity_id` - ) VALUES (55, 'civicrm_group', {$this->_permissionedGroup}); + `acl_role_id`, `entity_table`, `entity_id`, `is_active` + ) VALUES (55, 'civicrm_group', {$this->_permissionedGroup}, 1); "); - CRM_Core_DAO::executeQuery(" - INSERT INTO civicrm_acl ( - `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active` - ) - VALUES ( - 'view picked', 'civicrm_group', $this->_permissionedGroup , 'Edit', 'civicrm_saved_search', {$this->_permissionedGroup}, 1 - ); - "); + if ($isProfile) { + CRM_Core_DAO::executeQuery(" + INSERT INTO civicrm_acl ( + `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active` + ) + VALUES ( + 'view picked', 'civicrm_acl_role', 55, 'Edit', 'civicrm_uf_group', 0, 1 + ); + "); + } + else { + CRM_Core_DAO::executeQuery(" + INSERT INTO civicrm_acl ( + `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active` + ) + VALUES ( + 'view picked', 'civicrm_group', $this->_permissionedGroup , 'Edit', 'civicrm_saved_search', {$this->_permissionedGroup}, 1 + ); + "); + + CRM_Core_DAO::executeQuery(" + INSERT INTO civicrm_acl ( + `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active` + ) + VALUES ( + 'view picked', 'civicrm_group', $this->_permissionedGroup, 'Edit', 'civicrm_saved_search', {$this->_permissionedDisabledGroup}, 1 + ); + "); + } - CRM_Core_DAO::executeQuery(" - INSERT INTO civicrm_acl ( - `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active` - ) - VALUES ( - 'view picked', 'civicrm_group', $this->_permissionedGroup, 'Edit', 'civicrm_saved_search', {$this->_permissionedDisabledGroup}, 1 - ); - "); $this->_loggedInUser = CRM_Core_Session::singleton()->get('userID'); $this->callAPISuccess('group_contact', 'create', array( 'group_id' => $this->_permissionedGroup, 'contact_id' => $this->_loggedInUser, )); - //flush cache - CRM_ACL_BAO_Cache::resetCache(); - CRM_Contact_BAO_Group::getPermissionClause(TRUE); - CRM_ACL_API::groupPermission('whatever', 9999, NULL, 'civicrm_saved_search', NULL, NULL, TRUE); + + if (!$isProfile) { + //flush cache + CRM_ACL_BAO_Cache::resetCache(); + CRM_Contact_BAO_Group::getPermissionClause(TRUE); + CRM_ACL_API::groupPermission('whatever', 9999, NULL, 'civicrm_saved_search', NULL, NULL, TRUE); + } } /** @@ -3204,7 +3219,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'contact_id' => $this->_contactID, 'contribution_page_id' => $this->_contributionPageID, 'payment_processor_id' => $this->_paymentProcessorID, - 'is_test' => 1, + 'is_test' => 0, ), )); $this->_contributionRecurID = $contributionRecur['id'];