X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviUnitTestCase.php;h=32fb9e3ea9c964de122a45adbb03711e1929854e;hb=fa5e0fda22da5e17858fcffcff09561b408c35c7;hp=95d0bb3d62e0f422e83eeba2ff879fbe7f07bc80;hpb=35e93e6ad119df822d538bed2a7d80cb3492d589;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 95d0bb3d62..32fb9e3ea9 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -52,7 +52,7 @@ define('API_LATEST_VERSION', 3); * Common functions for unit tests * @package CiviCRM */ -class CiviUnitTestCase extends PHPUnit_Framework_TestCase { +class CiviUnitTestCase extends PHPUnit\Framework\TestCase { use \Civi\Test\Api3DocTrait; use \Civi\Test\GenericAssertionsTrait; @@ -195,7 +195,10 @@ class CiviUnitTestCase extends PHPUnit_Framework_TestCase { // FIXME: loosen coupling _civix_phpunit_setUp(); } - if (version_compare(PHPUnit_Runner_Version::id(), '5', '>=')) { + if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '5', '>=')) { + $this->mockMethod = 'createMock'; + } + elseif (class_exists('PHPUnit\Runner\Version') && version_compare(PHPUnit\Runner\Version::id(), '6', '>=')) { $this->mockMethod = 'createMock'; } } @@ -305,6 +308,8 @@ class CiviUnitTestCase extends PHPUnit_Framework_TestCase { $session = CRM_Core_Session::singleton(); $session->set('userID', NULL); + $this->_apiversion = 3; + // REVERT $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // Use a temporary file for STDIN @@ -451,6 +456,8 @@ class CiviUnitTestCase extends PHPUnit_Framework_TestCase { * Common teardown functions for all unit tests. */ protected function tearDown() { + $this->_apiversion = 3; + error_reporting(E_ALL & ~E_NOTICE); CRM_Utils_Hook::singleton()->reset(); if ($this->hookClass) { @@ -1372,7 +1379,7 @@ class CiviUnitTestCase extends PHPUnit_Framework_TestCase { $params['assignee_contact_id'] = $params['target_contact_id']; } - $result = $this->callAPISuccess('Activity', 'create', $params); + $result = civicrm_api3('Activity', 'create', $params); $result['target_contact_id'] = $params['target_contact_id']; $result['assignee_contact_id'] = $params['assignee_contact_id'];