}
}
+ /**
+ * @return bool
+ */
function requireDBReset() {
return $this->DBResetRequired;
}
+ /**
+ * @return string
+ */
static function getDBName() {
$dbName = !empty($GLOBALS['mysql_db']) ? $GLOBALS['mysql_db'] : 'civicrm_tests_dev';
return $dbName;
$GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
$env = new CRM_Utils_Check_Env();
- CRM_Utils_Check::singleton()->assertValid($env->checkAll());
+ CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime());
}
/**
else {
error_reporting(E_ALL & ~E_NOTICE);
}
+ $this->_sethtmlGlobals();
}
/**
}
// Request a record from the DB by seachColumn+searchValue. Success if a record is found.
+ /**
+ * @param $daoName
+ * @param $searchValue
+ * @param $returnColumn
+ * @param $searchColumn
+ * @param $message
+ *
+ * @return null|string
+ * @throws PHPUnit_Framework_AssertionFailedError
+ */
function assertDBNotNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
if (empty($searchValue)) {
$this->fail("empty value passed to assertDBNotNull");
}
// Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
+ /**
+ * @param $daoName
+ * @param $searchValue
+ * @param $returnColumn
+ * @param $searchColumn
+ * @param $message
+ */
function assertDBNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
$value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn, TRUE);
$this->assertNull($value, $message);
}
// Request a record from the DB by id. Success if row not found.
+ /**
+ * @param $daoName
+ * @param $id
+ * @param null $message
+ */
function assertDBRowNotExist($daoName, $id, $message = NULL) {
$message = $message ? $message : "$daoName (#$id) should not exist";
$value = CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id', TRUE);
}
// Request a record from the DB by id. Success if row not found.
+ /**
+ * @param $daoName
+ * @param $id
+ * @param null $message
+ */
function assertDBRowExist($daoName, $id, $message = NULL) {
$message = $message ? $message : "$daoName (#$id) should exist";
$value = CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id', TRUE);
}
// Compare a single column value in a retrieved DB record to an expected value
+ /**
+ * @param $daoName
+ * @param $searchValue
+ * @param $returnColumn
+ * @param $searchColumn
+ * @param $expectedValue
+ * @param $message
+ */
function assertDBCompareValue($daoName, $searchValue, $returnColumn, $searchColumn,
$expectedValue, $message
) {
}
// Compare all values in a single retrieved DB record to an array of expected values
+ /**
+ * @param $daoName
+ * @param $searchParams
+ * @param $expectedValues
+ */
function assertDBCompareValues($daoName, $searchParams, $expectedValues) {
//get the values from db
$dbValues = array();
$this->assertTrue(abs($actual - $expected) < $tolerance, $message);
}
+ /**
+ * @param $expectedValues
+ * @param $actualValues
+ * @param null $message
+ *
+ * @throws PHPUnit_Framework_AssertionFailedError
+ */
function assertAttributesEquals($expectedValues, $actualValues, $message = NULL) {
foreach ($expectedValues as $paramName => $paramValue) {
if (isset($actualValues[$paramName])) {
}
}
+ /**
+ * @param $key
+ * @param $list
+ */
function assertArrayKeyExists($key, &$list) {
$result = isset($list[$key]) ? TRUE : FALSE;
$this->assertTrue($result, ts("%1 element exists?",
));
}
+ /**
+ * @param $key
+ * @param $list
+ */
function assertArrayValueNotNull($key, &$list) {
$this->assertArrayKeyExists($key, $list);
$this->assertNotEmpty($apiResult['error_message']);
}
+ /**
+ * @param $expected
+ * @param $actual
+ * @param string $message
+ */
function assertType($expected, $actual, $message = '') {
return $this->assertInternalType($expected, $actual, $message);
}
* - array
* - object
*
+ * @throws Exception
* @return array|int
*/
function callAPISuccessGetSingle($entity, $params, $checkAgainst = NULL) {
return $result['id'];
}
+ /**
+ * @param $contactID
+ *
+ * @return array|int
+ */
function contactDelete($contactID) {
$params = array(
'id' => $contactID,
return $result;
}
+ /**
+ * @param $contactTypeId
+ *
+ * @throws Exception
+ */
function contactTypeDelete($contactTypeId) {
require_once 'CRM/Contact/BAO/ContactType.php';
$result = CRM_Contact_BAO_ContactType::del($contactTypeId);
}
}
+ /**
+ * @param array $params
+ *
+ * @return mixed
+ */
function membershipTypeCreate($params = array()) {
CRM_Member_PseudoConstant::flush('membershipType');
CRM_Core_Config::clearDBCache();
'financial_type_id' => 1,
'is_active' => 1,
'sequential' => 1,
- 'visibility' => 1,
+ 'visibility' => 'Public',
), $params);
$result = $this->callAPISuccess('MembershipType', 'Create', $params);
return $result['id'];
}
+ /**
+ * @param $params
+ *
+ * @return mixed
+ */
function contactMembershipCreate($params) {
$pre = array(
'join_date' => '2007-01-21',
* @internal param int $membershipTypeID
*/
function membershipTypeDelete($params) {
- $result = $this->callAPISuccess('MembershipType', 'Delete', $params);
- return;
+ $this->callAPISuccess('MembershipType', 'Delete', $params);
}
+ /**
+ * @param $membershipID
+ */
function membershipDelete($membershipID) {
$deleteParams = array('id' => $membershipID);
$result = $this->callAPISuccess('Membership', 'Delete', $deleteParams);
return;
}
+ /**
+ * @param string $name
+ *
+ * @return mixed
+ */
function membershipStatusCreate($name = 'test member status') {
$params['name'] = $name;
$params['start_event'] = 'start_date';
return $result['id'];
}
+ /**
+ * @param $membershipStatusID
+ */
function membershipStatusDelete($membershipStatusID) {
if (!$membershipStatusID) {
return;
return;
}
+ /**
+ * @param array $params
+ *
+ * @return mixed
+ */
function relationshipTypeCreate($params = array()) {
$params = array_merge(array(
'name_a_b' => 'Relation 1 for relationship type create',
$this->callAPISuccess('relationship_type', 'delete', $params);
}
+ /**
+ * @param null $params
+ *
+ * @return mixed
+ */
function paymentProcessorTypeCreate($params = NULL) {
if (is_null($params)) {
$params = array(
return $this->callAPISuccess('custom_field', 'create', $params);
}
+ /**
+ * @param $entities
+ *
+ * @return bool
+ */
function confirmEntitiesDeleted($entities) {
foreach ($entities as $entity) {
}
}
+ /**
+ * @param $tablesToTruncate
+ * @param bool $dropCustomValueTables
+ */
function quickCleanup($tablesToTruncate, $dropCustomValueTables = FALSE) {
if ($dropCustomValueTables) {
$tablesToTruncate[] = 'civicrm_custom_group';
'civicrm_membership',
'civicrm_membership_type',
'civicrm_membership_payment',
+ 'civicrm_membership_log',
'civicrm_membership_status',
'civicrm_event',
'civicrm_participant',
* @param string $errorText text to print on error
*
*/
+ /**
+ * @param $params
+ * @param $id
+ * @param $entity
+ * @param int $delete
+ * @param string $errorText
+ *
+ * @throws Exception
+ */
function getAndCheck($params, $id, $entity, $delete = 1, $errorText = '') {
$result = $this->callAPISuccessGetSingle($entity, array(
}
}
+ /**
+ * @param $name
+ */
function financialAccountDelete($name) {
$financialAccount = new CRM_Financial_DAO_FinancialAccount();
$financialAccount->name = $name;
CRM_ACL_API::groupPermission('whatever', 9999, NULL, 'civicrm_saved_search', NULL, NULL, TRUE);
}
+ /**
+ * alter default price set so that the field numbers are not all 1 (hiding errors)
+ */
+ function offsetDefaultPriceSet() {
+ $contributionPriceSet = $this->callAPISuccess('price_set', 'getsingle', array('name' => 'default_contribution_amount'));
+ $firstID = $contributionPriceSet['id'];
+ $this->callAPISuccess('price_set', 'create', array('id' => $contributionPriceSet['id'], 'is_active' => 0, 'name' => 'old'));
+ unset($contributionPriceSet['id']);
+ $newPriceSet = $this->callAPISuccess('price_set', 'create', $contributionPriceSet);
+ $priceField = $this->callAPISuccess('price_field', 'getsingle', array('price_set_id' => $firstID, 'options' => array('limit' => 1)));
+ unset($priceField['id']);
+ $priceField['price_set_id'] = $newPriceSet['id'];
+ $newPriceField = $this->callAPISuccess('price_field', 'create', $priceField);
+ $priceFieldValue = $this->callAPISuccess('price_field_value', 'getsingle', array('price_set_id' => $firstID, 'sequential' => 1, 'options' => array('limit' => 1)));
+
+ unset($priceFieldValue['id']);
+ //create some padding to use up ids
+ $this->callAPISuccess('price_field_value', 'create', $priceFieldValue);
+ $this->callAPISuccess('price_field_value', 'create', $priceFieldValue);
+ $this->callAPISuccess('price_field_value', 'create', array_merge($priceFieldValue, array('price_field_id' => $newPriceField['id'])));
+
+ }
+
/**
* Create an instance of the paypal processor
* @todo this isn't a great place to put it - but really it belongs on a class that extends
}
-function CiviUnitTestCase_fatalErrorHandler($message) {
+ /**
+ * @param $message
+ *
+ * @throws Exception
+ */function CiviUnitTestCase_fatalErrorHandler($message) {
throw new Exception("{$message['message']}: {$message['code']}");
}
}