* 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;
// 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';
}
}
$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
* 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) {
$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'];
));
}
+ /**
+ * Assert 2 sql strings are the same, ignoring double spaces.
+ *
+ * @param string $expectedSQL
+ * @param string $actualSQL
+ * @param string $message
+ */
+ protected function assertLike($expectedSQL, $actualSQL, $message = 'different sql') {
+ $expected = trim((preg_replace('/[ \r\n\t]+/', ' ', $expectedSQL)));
+ $actual = trim((preg_replace('/[ \r\n\t]+/', ' ', $actualSQL)));
+ $this->assertEquals($expected, $actual, $message);
+ }
+
/**
* Create a price set for an event.
*