// also load the class loader
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
- if (function_exists('_civix_phpunit_setUp')) { // FIXME: loosen coupling
+ if (function_exists('_civix_phpunit_setUp')) {
+ // FIXME: loosen coupling
_civix_phpunit_setUp();
}
}
+ /**
+ * Override to run the test and assert its state.
+ * @return mixed
+ * @throws \Exception
+ * @throws \PHPUnit_Framework_IncompleteTest
+ * @throws \PHPUnit_Framework_SkippedTest
+ */
protected function runTest() {
try {
return parent::runTest();
* @match array Associative array of field name => expected value. Empty if asserting
* that a DELETE occurred
* @delete boolean True if we're checking that a DELETE action occurred.
+ * @param $daoName
+ * @param $id
+ * @param $match
+ * @param bool $delete
+ * @throws \PHPUnit_Framework_AssertionFailedError
*/
public function assertDBState($daoName, $id, $match, $delete = FALSE) {
if (empty($id)) {
* @param $expectedValue
* @param $message
*/
- function assertDBCompareValue(
+ public function assertDBCompareValue(
$daoName, $searchValue, $returnColumn, $searchColumn,
$expectedValue, $message
) {
*
* Example: $this->assertSql(2, 'select count(*) from foo where foo.bar like "%1"',
* array(1 => array("Whiz", "String")));
+ * @param $expected
+ * @param $query
+ * @param array $params
+ * @param string $message
*/
public function assertDBQuery($expected, $query, $params = array(), $message = '') {
if ($message) {
/**
* Check that a deleted item has been deleted
+ * @param $entity
+ * @param $id
*/
public function assertAPIDeleted($entity, $id) {
$this->callAPISuccess($entity, 'getcount', array('id' => $id), 0);
'debug' => 1,
);
$result = $this->civicrm_api($entity, 'getcount', $params);
- if (!is_integer($result) || !empty($result['is_error']) || isset($result['values'])) {
+ if (!is_int($result) || !empty($result['is_error']) || isset($result['values'])) {
throw new Exception('Invalid getcount result : ' . print_r($result, TRUE) . " type :" . gettype($result));
}
if (is_int($count)) {
);
$params = array('contact_type' => $contact_type);
foreach ($samples[$contact_type] as $key => $values) {
- $params[$key] = $values[$seq % sizeof($values)];
+ $params[$key] = $values[$seq % count($values)];
}
if ($contact_type == 'Individual') {
$params['email'] = strtolower(
* Contact ID to delete
*/
public function contactDelete($contactID) {
- $domain = new CRM_Core_BAO_Domain;
+ $domain = new CRM_Core_BAO_Domain();
$domain->contact_id = $contactID;
if (!$domain->find(TRUE)) {
$this->callAPISuccess('contact', 'delete', array(
* @throws Exception
*/
public function contactTypeDelete($contactTypeId) {
- require_once 'CRM/Contact/BAO/ContactType.php';
$result = CRM_Contact_BAO_ContactType::del($contactTypeId);
if (!$result) {
throw new Exception('Could not delete contact type');
public function membershipDelete($membershipID) {
$deleteParams = array('id' => $membershipID);
$result = $this->callAPISuccess('Membership', 'Delete', $deleteParams);
- return;
}
/**
return;
}
$result = $this->callAPISuccess('MembershipStatus', 'Delete', array('id' => $membershipStatusID));
- return;
}
/**
/**
* Delete a Location Type
*
- * @param int location type id
+ * @param int $locationTypeId
*/
public function locationTypeDelete($locationTypeId) {
$locationType = new CRM_Core_DAO_LocationType();
*
* @params array to add group
*
- * @param array $params
+ * @param int $groupID
+ * @param int $totalCount
* @return int
- * groupId of created group
+ * groupId of created group
*/
public function groupContactCreate($groupID, $totalCount = 10) {
$params = array('group_id' => $groupID);
/**
* Delete a UF Join Entry
*
- * @param array with missing uf_group_id
+ * @param array $params
+ * with missing uf_group_id
*/
public function ufjoinDelete($params = NULL) {
if ($params === NULL) {
*
* @param array $params
* Parameters.
+ * @return array
*/
public function activityTypeCreate($params) {
- $result = $this->callAPISuccess('ActivityType', 'create', $params);
- return $result;
+ return $this->callAPISuccess('ActivityType', 'create', $params);
}
/**
*
* @param int $activityTypeId
* Id of the activity type.
+ * @return array
*/
public function activityTypeDelete($activityTypeId) {
$params['activity_type_id'] = $activityTypeId;
- $result = $this->callAPISuccess('ActivityType', 'delete', $params);
- return $result;
+ return $this->callAPISuccess('ActivityType', 'delete', $params);
}
/**
/**
* Existing function doesn't allow params to be over-ridden so need a new one
* this one allows you to only pass in the params you want to change
+ * @param array $params
+ * @return array|int
*/
public function CustomGroupCreateByParams($params = array()) {
$defaults = array(
/**
* Create custom group with multi fields
+ * @param array $params
+ * @return array|int
*/
public function CustomGroupMultipleCreateByParams($params = array()) {
$defaults = array(
/**
* Create custom group with multi fields
+ * @param array $params
+ * @return array
*/
public function CustomGroupMultipleCreateWithFields($params = array()) {
// also need to pass on $params['custom_field'] if not set but not in place yet
return TRUE;
}
}
+ return FALSE;
}
/**
/**
* Temporarily replace the singleton extension with a different one
+ * @param \CRM_Extension_System $system
*/
public function setExtensionSystem(CRM_Extension_System $system) {
if ($this->origExtensionSystem == NULL) {
* this parent class & we don't have a structure for that yet
* There is another function to this effect on the PaypalPro test but it appears to be silently failing
* & the best protection agains that is the functions this class affords
+ * @param array $params
+ * @return int $result['id'] payment processor id
*/
public function paymentProcessorCreate($params = array()) {
$params = array_merge(array(
ob_end_clean();
}
}
+
}