* @param $expectedValue
* @param string $message
*/
- function assertDBCompareValue(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn,
+ function assertDBCompareValue(
+ &$testCase, $daoName, $searchValue, $returnColumn, $searchColumn,
$expectedValue, $message
) {
$value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn);
/**
* Authenticate as drupal user
- * @param $user: (str) the key 'user' or 'admin', or a literal username
- * @param $pass: (str) if $user is a literal username and not 'user' or 'admin', supply the password
+ * @param $user : (str) the key 'user' or 'admin', or a literal username
+ * @param $pass : (str) if $user is a literal username and not 'user' or 'admin', supply the password
*/
public function webtestLogin($user = 'user', $pass = NULL) {
// If already logged in as correct user, do nothing
else {
$params[strtolower($contactType) . '_name'] = "$name $contactType";
}
- foreach($params as $param => $val) {
+ foreach ($params as $param => $val) {
$this->type($param, $val);
}
$this->type('email-Primary', $params['email'] = "{$name}@example.com");
/**
* @deprecated in favor of createDialogContact
*/
- function webtestNewDialogContact($fname = 'Anthony', $lname = 'Anderson', $email = 'anthony@anderson.biz',
- $type = 4, $selectId = 's2id_contact_id', $row = 1, $prefix = '') {
+ function webtestNewDialogContact(
+ $fname = 'Anthony', $lname = 'Anderson', $email = 'anthony@anderson.biz',
+ $type = 4, $selectId = 's2id_contact_id', $row = 1, $prefix = '') {
// 4 - Individual profile
// 5 - Organization profile
// 6 - Household profile
*
* @return null $pageId of newly created online contribution page.
*/
- function webtestAddContributionPage($hash = NULL,
- $rand = NULL,
- $pageTitle = NULL,
- $processor = array('Test Processor' => 'Dummy'),
- $amountSection = TRUE,
- $payLater = TRUE,
- $onBehalf = TRUE,
- $pledges = TRUE,
- $recurring = FALSE,
- $membershipTypes = TRUE,
- $memPriceSetId = NULL,
- $friend = TRUE,
- $profilePreId = 1,
- $profilePostId = 7,
- $premiums = TRUE,
- $widget = TRUE,
- $pcp = TRUE,
- $isAddPaymentProcessor = TRUE,
- $isPcpApprovalNeeded = FALSE,
- $isSeparatePayment = FALSE,
- $honoreeSection = TRUE,
- $allowOtherAmount = TRUE,
- $isConfirmEnabled = TRUE,
- $financialType = 'Donation',
- $fixedAmount = TRUE,
- $membershipsRequired = TRUE
+ function webtestAddContributionPage(
+ $hash = NULL,
+ $rand = NULL,
+ $pageTitle = NULL,
+ $processor = array('Test Processor' => 'Dummy'),
+ $amountSection = TRUE,
+ $payLater = TRUE,
+ $onBehalf = TRUE,
+ $pledges = TRUE,
+ $recurring = FALSE,
+ $membershipTypes = TRUE,
+ $memPriceSetId = NULL,
+ $friend = TRUE,
+ $profilePreId = 1,
+ $profilePostId = 7,
+ $premiums = TRUE,
+ $widget = TRUE,
+ $pcp = TRUE,
+ $isAddPaymentProcessor = TRUE,
+ $isPcpApprovalNeeded = FALSE,
+ $isSeparatePayment = FALSE,
+ $honoreeSection = TRUE,
+ $allowOtherAmount = TRUE,
+ $isConfirmEnabled = TRUE,
+ $financialType = 'Donation',
+ $fixedAmount = TRUE,
+ $membershipsRequired = TRUE
) {
if (!$hash) {
$hash = substr(sha1(rand()), 0, 7);
* @param $expectedValue
* @param string $message
*/
- function assertDBCompareValue($daoName, $searchValue, $returnColumn, $searchColumn,
- $expectedValue, $message
+ function assertDBCompareValue(
+ $daoName, $searchValue, $returnColumn, $searchColumn,
+ $expectedValue, $message
) {
if (!self::checkDoLocalDBTest()) {
return;
/**
* Add new Financial Account
*/
- function _testAddFinancialAccount($financialAccountTitle,
- $financialAccountDescription = FALSE,
- $accountingCode = FALSE,
- $firstName = FALSE,
- $financialAccountType = FALSE,
- $taxDeductible = FALSE,
- $isActive = FALSE,
- $isTax = FALSE,
- $taxRate = FALSE,
- $isDefault = FALSE
+ function _testAddFinancialAccount(
+ $financialAccountTitle,
+ $financialAccountDescription = FALSE,
+ $accountingCode = FALSE,
+ $firstName = FALSE,
+ $financialAccountType = FALSE,
+ $taxDeductible = FALSE,
+ $isActive = FALSE,
+ $isTax = FALSE,
+ $taxRate = FALSE,
+ $isDefault = FALSE
) {
$this->openCiviPage("admin/financial/financialAccount", "reset=1");
/**
* Edit Financial Account
*/
- function _testEditFinancialAccount($editfinancialAccount,
+ function _testEditFinancialAccount(
+ $editfinancialAccount,
$financialAccountTitle = FALSE,
$financialAccountDescription = FALSE,
$accountingCode = FALSE,
*
* @param array $customSets
* Custom sets i.e entity wise sets want to be created and checked.
- e.g $customSets = array(array('entity' => 'Contribution', 'subEntity' => 'Donation',
- 'triggerElement' => $triggerElement))
- array $triggerElement: the element which is responsible for custom group to load
-
- which uses the entity info as its selection value
+ * e.g $customSets = array(array('entity' => 'Contribution', 'subEntity' => 'Donation',
+ * 'triggerElement' => $triggerElement))
+ * array $triggerElement: the element which is responsible for custom group to load
+ *
+ * which uses the entity info as its selection value
* @param array $pageUrl
* The url which on which the ajax custom group load takes place.
* @param bool $beforeTriggering
$this->waitForAjaxContent();
$this->checkForErrorsOnPage();
- foreach($return as $values) {
+ foreach ($return as $values) {
foreach ($values as $entityType => $customData) {
//initiate necessary variables
list($entity, $entityData) = explode('_', $entityType);
}
elseif ($elementType == 'checkbox') {
$val = explode(',', $entityData);
- foreach($val as $v) {
+ foreach ($val as $v) {
$checkId = $this->getAttribute("xpath=//label[text()='{$v}']/@for");
$this->check($checkId);
}
$customGroupTitle = preg_replace('/\s/', '_', trim($customGroupTitle));
$return[] = array(
- "{$customSet['entity']}_{$customSet['subEntity']}" => array('cgtitle' => $customGroupTitle, 'gid' => $gid, 'triggerElement' => $customSet['triggerElement']));
+ "{$customSet['entity']}_{$customSet['subEntity']}" => array(
+ 'cgtitle' => $customGroupTitle,
+ 'gid' => $gid,
+ 'triggerElement' => $customSet['triggerElement']
+ )
+ );
// Go home for a sec to give time for caches to clear
$this->openCiviPage('');
public function multiselect2($fieldid, $params) {
// In the case of chainSelect, wait for options to load
$this->waitForElementNotPresent('css=select.loading');
- foreach($params as $value) {
+ foreach ($params as $value) {
$this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input");
$this->waitForElementPresent("xpath=//ul[@class='select2-results']");
$this->clickAt("xpath=//ul[@class='select2-results']//li/div[text()='$value']");
* @internal param \Directory $object to scan
* @return Test suite has been updated
*/
- protected function addAllTests(PHPUnit_Framework_TestSuite & $suite,
- $myfile, SplFileInfo $dirInfo
+ protected function addAllTests(
+ PHPUnit_Framework_TestSuite &$suite,
+ $myfile, SplFileInfo $dirInfo
) {
//echo get_class($this)."::addAllTests($myfile,".$dirInfo->getRealPath().")\n";
if (!$dirInfo->isReadable()
protected function runTest() {
try {
return parent::runTest();
- } catch (PEAR_Exception $e) {
+ }
+ catch (PEAR_Exception $e) {
// PEAR_Exception has metadata in funny places, and PHPUnit won't log it nicely
throw new Exception(\CRM_Core_Error::formatTextException($e), $e->getCode());
}
civicrm_api('system', 'flush', array('version' => 3, 'triggers' => 1));
CRM_Core_BAO_ConfigSetting::setEnabledComponents(array(
- 'CiviEvent', 'CiviContribute', 'CiviMember', 'CiviMail', 'CiviReport', 'CiviPledge'
+ 'CiviEvent',
+ 'CiviContribute',
+ 'CiviMember',
+ 'CiviMail',
+ 'CiviReport',
+ 'CiviPledge'
));
return TRUE;
CRM_Core_Transaction::forceRollbackIfEnabled();
\Civi\Core\Transaction\Manager::singleton(TRUE);
- } else {
+ }
+ else {
CRM_Core_Transaction::forceRollbackIfEnabled();
\Civi\Core\Transaction\Manager::singleton(TRUE);
// Otherwise check matches of DAO field values against expected values in $match.
if ($object->find(TRUE)) {
- $fields = & $object->fields();
+ $fields = &$object->fields();
foreach ($fields as $name => $value) {
$dbName = $value['name'];
if (isset($match[$name])) {
* @param $expectedValue
* @param $message
*/
- function assertDBCompareValue($daoName, $searchValue, $returnColumn, $searchColumn,
- $expectedValue, $message
+ function assertDBCompareValue(
+ $daoName, $searchValue, $returnColumn, $searchColumn,
+ $expectedValue, $message
) {
$value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn, TRUE);
$this->assertEquals($value, $expectedValue, $message);
* array(1 => array("Whiz", "String")));
*/
public function assertDBQuery($expected, $query, $params = array(), $message = '') {
- if ($message) { $message .= ': ';
+ if ($message) {
+ $message .= ': ';
}
$actual = CRM_Core_DAO::singleValueQuery($query, $params);
$this->assertEquals($expected, $actual,
public function assertAttributesEquals($expectedValues, $actualValues, $message = NULL) {
foreach ($expectedValues as $paramName => $paramValue) {
if (isset($actualValues[$paramName])) {
- $this->assertEquals($paramValue, $actualValues[$paramName], "Value Mismatch On $paramName - value 1 is " . print_r($paramValue, TRUE) . " value 2 is " . print_r($actualValues[$paramName], TRUE) );
+ $this->assertEquals($paramValue, $actualValues[$paramName], "Value Mismatch On $paramName - value 1 is " . print_r($paramValue, TRUE) . " value 2 is " . print_r($actualValues[$paramName], TRUE));
}
else {
$this->fail("Attribute '$paramName' not present in actual array.");
}
$errorMessage = empty($apiResult['error_message']) ? '' : " " . $apiResult['error_message'];
- if(!empty($apiResult['debug_information'])) {
+ if (!empty($apiResult['debug_information'])) {
$errorMessage .= "\n " . print_r($apiResult['debug_information'], TRUE);
}
- if(!empty($apiResult['trace'])){
+ if (!empty($apiResult['trace'])) {
$errorMessage .= "\n" . print_r($apiResult['trace'], TRUE);
}
$this->assertEquals(0, $apiResult['is_error'], $prefix . $errorMessage);
if (!empty($prefix)) {
$prefix .= ': ';
}
- if($expectedError && !empty($apiResult['is_error'])){
- $this->assertEquals($expectedError, $apiResult['error_message'], 'api error message not as expected' . $prefix );
+ if ($expectedError && !empty($apiResult['is_error'])) {
+ $this->assertEquals($expectedError, $apiResult['error_message'], 'api error message not as expected' . $prefix);
}
$this->assertEquals(1, $apiResult['is_error'], "api call should have failed but it succeeded " . $prefix . (print_r($apiResult, TRUE)));
$this->assertNotEmpty($apiResult['error_message']);
public function assertAPIArrayComparison($result, $expected, $valuesToExclude = array(), $prefix = '') {
$valuesToExclude = array_merge($valuesToExclude, array('debug', 'xdebug', 'sequential'));
foreach ($valuesToExclude as $value) {
- if(isset($result[$value])) {
+ if (isset($result[$value])) {
unset($result[$value]);
}
- if(isset($expected[$value])) {
+ if (isset($expected[$value])) {
unset($expected[$value]);
}
}
'debug' => 1,
);
$result = $this->civicrm_api($entity, 'getvalue', $params);
- if($type){
- if($type == 'integer'){
+ if ($type) {
+ if ($type == 'integer') {
// api seems to return integers as strings
$this->assertTrue(is_numeric($result), "expected a numeric value but got " . print_r($result, 1));
}
- else{
- $this->assertType($type, $result, "returned result should have been of type $type but was " );
+ else {
+ $this->assertType($type, $result, "returned result should have been of type $type but was ");
}
}
return $result;
'debug' => 1,
);
$result = $this->civicrm_api($entity, 'getsingle', $params);
- if(!is_array($result) || !empty($result['is_error']) || isset($result['values'])) {
+ if (!is_array($result) || !empty($result['is_error']) || isset($result['values'])) {
throw new Exception('Invalid getsingle result' . print_r($result, TRUE));
}
- if($checkAgainst){
+ if ($checkAgainst) {
// @todo - have gone with the fn that unsets id? should we check id?
$this->checkArrayEquals($result, $checkAgainst);
}
'debug' => 1,
);
$result = $this->civicrm_api($entity, 'getcount', $params);
- if(!is_integer($result) || !empty($result['is_error']) || isset($result['values'])) {
+ if (!is_integer($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)){
+ if (is_int($count)) {
$this->assertEquals($count, $result, "incorrect count returned from $entity getcount");
}
return $result;
* @param string|null $actionName
* @return array|int
*/
- public function callAPIAndDocument($entity, $action, $params, $function, $file, $description = "", $subfile = NULL, $actionName = NULL){
+ public function callAPIAndDocument($entity, $action, $params, $function, $file, $description = "", $subfile = NULL, $actionName = NULL) {
$params['version'] = $this->_apiversion;
$result = $this->callAPISuccess($entity, $action, $params);
$this->documentMe($params, $result, $function, $file, $description, $subfile, $actionName);
*
* @return array api Result
*/
- public function createTestEntity(){
+ public function createTestEntity() {
return $entity = $this->callAPISuccess($this->entity, 'create', $this->params);
}
'last_name' => array('Anderson', 'Miller', 'Smith', 'Collins', 'Peterson'),
),
'Organization' => array(
- 'organization_name' => array('Unit Test Organization', 'Acme', 'Roberts and Sons', 'Cryo Space Labs', 'Sharper Pens'),
+ 'organization_name' => array(
+ 'Unit Test Organization',
+ 'Acme',
+ 'Roberts and Sons',
+ 'Cryo Space Labs',
+ 'Sharper Pens'
+ ),
),
'Household' => array(
'household_name' => array('Unit Test household'),
foreach ($samples[$contact_type] as $key => $values) {
$params[$key] = $values[$seq % sizeof($values)];
}
- if ($contact_type == 'Individual' ) {
+ if ($contact_type == 'Individual') {
$params['email'] = strtolower(
- $params['first_name'] . '_' . $params['last_name'] . '@civicrm.org'
- );
+ $params['first_name'] . '_' . $params['last_name'] . '@civicrm.org'
+ );
$params['prefix_id'] = 3;
$params['suffix_id'] = 3;
}
'is_reserved' => 1,
'is_active' => 1,
),
- $params
+ $params
);
$result = $this->callAPISuccess('relationship_type', 'create', $params);
* @return int $id of participant created
*/
public function participantCreate($params) {
- if(empty($params['contact_id'])){
+ if (empty($params['contact_id'])) {
$params['contact_id'] = $this->individualCreate();
}
- if(empty($params['event_id'])){
+ if (empty($params['event_id'])) {
$event = $this->eventCreate();
$params['event_id'] = $event['id'];
}
*/
public function groupCreate($params = array()) {
$params = array_merge(array(
- 'name' => 'Test Group 1',
- 'domain_id' => 1,
- 'title' => 'New Test Group Created',
- 'description' => 'New Test Group Created',
- 'is_active' => 1,
- 'visibility' => 'Public Pages',
- 'group_type' => array(
- '1' => 1,
- '2' => 1,
- ),
- ), $params);
+ 'name' => 'Test Group 1',
+ 'domain_id' => 1,
+ 'title' => 'New Test Group Created',
+ 'description' => 'New Test Group Created',
+ 'is_active' => 1,
+ 'visibility' => 'Public Pages',
+ 'group_type' => array(
+ '1' => 1,
+ '2' => 1,
+ ),
+ ), $params);
$result = $this->callAPISuccess('Group', 'create', $params);
return $result['id'];
}
//have a crack @ deleting it first in the hope this will prevent derailing our tests
- $this->callAPISuccess('custom_group', 'get', array('title' => $params['title'], array('api.custom_group.delete' => 1)));
+ $this->callAPISuccess('custom_group', 'get', array(
+ 'title' => $params['title'],
+ array('api.custom_group.delete' => 1)
+ ));
return $this->callAPISuccess('custom_group', 'create', $params);
}
$customGroup = $this->CustomGroupMultipleCreateByParams($params);
$ids['custom_group_id'] = $customGroup['id'];
- $customField = $this->customFieldCreate(array('custom_group_id' => $ids['custom_group_id'], 'label' => 'field_1' . $ids['custom_group_id']));
+ $customField = $this->customFieldCreate(array(
+ 'custom_group_id' => $ids['custom_group_id'],
+ 'label' => 'field_1' . $ids['custom_group_id']
+ ));
$ids['custom_field_id'][] = $customField['id'];
- $customField = $this->customFieldCreate(array('custom_group_id' => $ids['custom_group_id'], 'default_value' => '', 'label' => 'field_2' . $ids['custom_group_id']));
+ $customField = $this->customFieldCreate(array(
+ 'custom_group_id' => $ids['custom_group_id'],
+ 'default_value' => '',
+ 'label' => 'field_2' . $ids['custom_group_id']
+ ));
$ids['custom_field_id'][] = $customField['id'];
- $customField = $this->customFieldCreate(array('custom_group_id' => $ids['custom_group_id'], 'default_value' => '', 'label' => 'field_3' . $ids['custom_group_id']));
+ $customField = $this->customFieldCreate(array(
+ 'custom_group_id' => $ids['custom_group_id'],
+ 'default_value' => '',
+ 'label' => 'field_3' . $ids['custom_group_id']
+ ));
$ids['custom_field_id'][] = $customField['id'];
return $ids;
}
$this->tidyExampleResult($result);
- if(isset($params['version'])) {
+ if (isset($params['version'])) {
unset($params['version']);
}
// a cleverer person than me would do it in a single regex
* @param array $result
*
*/
- public function tidyExampleResult(&$result){
- if(!is_array($result)) {
+ public function tidyExampleResult(&$result) {
+ if (!is_array($result)) {
return;
}
$fieldsToChange = array(
$keysToUnset = array('xdebug', 'undefined_fields');
foreach ($keysToUnset as $unwantedKey) {
- if(isset($result[$unwantedKey])) {
+ if (isset($result[$unwantedKey])) {
unset($result[$unwantedKey]);
}
}
if (isset($result['values'])) {
- if(!is_array($result['values'])) {
+ if (!is_array($result['values'])) {
return;
}
$resultArray = &$result['values'];
}
- elseif(is_array($result)) {
+ elseif (is_array($result)) {
$resultArray = &$result;
}
else {
}
foreach ($resultArray as $index => &$values) {
- if(!is_array($values)) {
+ if (!is_array($values)) {
continue;
}
- foreach($values as $key => &$value) {
- if(substr($key, 0, 3) == 'api' && is_array($value)) {
- if(isset($value['is_error'])) {
+ foreach ($values as $key => &$value) {
+ if (substr($key, 0, 3) == 'api' && is_array($value)) {
+ if (isset($value['is_error'])) {
// we have a std nested result format
$this->tidyExampleResult($value);
}
- else{
+ else {
foreach ($value as &$nestedResult) {
// this is an alternative syntax for nested results a keyed array of results
$this->tidyExampleResult($nestedResult);
}
}
}
- if(in_array($key, $keysToUnset)) {
+ if (in_array($key, $keysToUnset)) {
unset($values[$key]);
break;
}
- if(array_key_exists($key, $fieldsToChange) && !empty($value)) {
+ if (array_key_exists($key, $fieldsToChange) && !empty($value)) {
$value = $fieldsToChange[$key];
}
- if(is_string($value)) {
+ if (is_string($value)) {
$value = addslashes($value);
}
}
if ($type == CRM_Utils_Type::T_DATE) {
$dateFields[] = $settings['name'];
// we should identify both real names & unique names as dates
- if($field != $settings['name']) {
+ if ($field != $settings['name']) {
$dateFields[] = $field;
}
}
- if($type == CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME) {
+ if ($type == CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME) {
$dateTimeFields[] = $settings['name'];
// we should identify both real names & unique names as dates
- if($field != $settings['name']) {
+ if ($field != $settings['name']) {
$dateTimeFields[] = $field;
}
}
$this->callAPISuccess('system', 'flush', array());
CRM_Core_BAO_Setting::$_cache = array();
- CRM_Utils_Hook::singleton()->setHook('civicrm_alterSettingsMetaData', function (&$metadata, $domainId, $profile) use ($extras) {
- $metadata = array_merge($metadata, $extras);
- });
+ CRM_Utils_Hook::singleton()
+ ->setHook('civicrm_alterSettingsMetaData', function (&$metadata, $domainId, $profile) use ($extras) {
+ $metadata = array_merge($metadata, $extras);
+ });
$fields = $this->callAPISuccess('setting', 'getfields', array());
foreach ($extras as $key => $spec) {
public function financialAccountDelete($name) {
$financialAccount = new CRM_Financial_DAO_FinancialAccount();
$financialAccount->name = $name;
- if($financialAccount->find(TRUE)) {
+ if ($financialAccount->find(TRUE)) {
$entityFinancialType = new CRM_Financial_DAO_EntityFinancialAccount();
$entityFinancialType->financial_account_id = $financialAccount->id;
$entityFinancialType->delete();
CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM');
$optionGroupID = $this->callAPISuccessGetValue('option_group', array('return' => 'id', 'name' => 'acl_role'));
$optionValue = $this->callAPISuccess('option_value', 'create', array(
- 'option_group_id' => $optionGroupID,
+ 'option_group_id' => $optionGroupID,
'label' => 'pick me',
'value' => 55,
));
public 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'));
+ $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)));
+ $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)));
+ $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
*/
public function paymentProcessorCreate($params = array()) {
$params = array_merge(array(
- 'name' => 'demo',
- 'domain_id' => CRM_Core_Config::domainID(),
- 'payment_processor_type_id' => 'PayPal',
- 'is_active' => 1,
- 'is_default' => 0,
- 'is_test' => 1,
- 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in',
- 'password' => '1183377788',
- 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH',
- 'url_site' => 'https://www.sandbox.paypal.com/',
- 'url_api' => 'https://api-3t.sandbox.paypal.com/',
- 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',
- 'class_name' => 'Payment_PayPalImpl',
- 'billing_mode' => 3,
- 'financial_type_id' => 1,
- ),
- $params);
- if(!is_numeric($params['payment_processor_type_id'])) {
+ 'name' => 'demo',
+ 'domain_id' => CRM_Core_Config::domainID(),
+ 'payment_processor_type_id' => 'PayPal',
+ 'is_active' => 1,
+ 'is_default' => 0,
+ 'is_test' => 1,
+ 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in',
+ 'password' => '1183377788',
+ 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH',
+ 'url_site' => 'https://www.sandbox.paypal.com/',
+ 'url_api' => 'https://api-3t.sandbox.paypal.com/',
+ 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',
+ 'class_name' => 'Payment_PayPalImpl',
+ 'billing_mode' => 3,
+ 'financial_type_id' => 1,
+ ),
+ $params);
+ if (!is_numeric($params['payment_processor_type_id'])) {
// really the api should handle this through getoptions but it's not exactly api call so lets just sort it
//here
$params['payment_processor_type_id'] = $this->callAPISuccess('payment_processor_type', 'getvalue', array(
'unit_price' => 200,
'line_total' => 200,
'financial_type_id' => 1,
- 'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', array('return' => 'id', 'label' => 'Membership Amount')),
- 'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', array('return' => 'id', 'label' => 'General')),
+ 'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', array(
+ 'return' => 'id',
+ 'label' => 'Membership Amount'
+ )),
+ 'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', array(
+ 'return' => 'id',
+ 'label' => 'General'
+ )),
));
- $this->callAPISuccess('membership_payment', 'create', array('contribution_id' => $this->_contributionID, 'membership_id' => $this->ids['membership']));
+ $this->callAPISuccess('membership_payment', 'create', array(
+ 'contribution_id' => $this->_contributionID,
+ 'membership_id' => $this->ids['membership']
+ ));
}
/**
* @param $email1
* @param $email2
*/
- function _testEventRegistration($eventPageId, $customId, $firstName, $lastName,
- $participantfname, $participantlname, $email1, $email2
+ function _testEventRegistration(
+ $eventPageId, $customId, $firstName, $lastName,
+ $participantfname, $participantlname, $email1, $email2
) {
$this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom");
$this->select("additional_participants", "value=1");
* saveMappingName : to override mapping name
*
*/
- function importCSVComponent($component,
+ function importCSVComponent(
+ $component,
$headers,
$rows,
$contactType = 'Individual',
* @package CiviCRM_APIv3
* @subpackage API_Contact
*/
-
class api_v3_ACLCachingTest extends CiviUnitTestCase {
protected $_apiversion = 3;
protected $_params;
public function setUp() {
parent::setUp();
}
+
/**
* (non-PHPdoc)
* @see CiviUnitTestCase::tearDown()
* @package CiviCRM_APIv3
* @subpackage API_Contact
*/
-
class api_v3_ACLPermissionTest extends CiviUnitTestCase {
protected $_apiversion = 3;
public $DBResetRequired = FALSE;
public function setupCoreACL() {
$this->createLoggedInUser();
- $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'));
+ $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'
+ ));
$this->setupACL();
}
+
/**
* @dataProvider entities
* confirm that without check permissions we still get 2 contacts returned
));
$this->assertEquals(2, $result['count']);
}
+
/**
* @dataProvider entities
* confirm that with check permissions we don't get entities
*/
public function setUpEntities($entity) {
$baoObj = new CRM_Core_DAO();
- $baoObj->createTestObject( _civicrm_api3_get_BAO($entity), array(), 2, 0);
+ $baoObj->createTestObject(_civicrm_api3_get_BAO($entity), array(), 2, 0);
CRM_Core_Config::singleton()->userPermissionClass->permissions = array(
'access CiviCRM',
'access CiviContribute',
parent::setUp();
$this->useTransaction(TRUE);
- $this->_contactID = $this->organizationCreate();
- $activity = $this->activityCreate();
- $this->_activityID = $activity['id'];
+ $this->_contactID = $this->organizationCreate();
+ $activity = $this->activityCreate();
+ $this->_activityID = $activity['id'];
CRM_Core_PseudoConstant::flush();
$this->_params = array(
'contact_id' => $this->_contactID,
'location_type_id' => $this->_locationType->id,
'contact_id' => $this->_contactID,
);
- $subfile = "AddressParse";
+ $subfile = "AddressParse";
$description = "Demonstrates Use of address parsing param";
$result = $this->callAPIAndDocument('address', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals(54, $result['values'][$result['id']]['street_number'], 'In line ' . __LINE__);
'master_id' => $address['id'],
);
$this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams));
- $this->callAPISuccess('relationship', 'getcount', array('contact_id_a' => $individualID, 'contact_id_b' => $this->_contactID));
+ $this->callAPISuccess('relationship', 'getcount', array(
+ 'contact_id_a' => $individualID,
+ 'contact_id_b' => $this->_contactID
+ ));
}
/**
'master_id' => $address['id'],
);
$this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams));
- $this->callAPISuccess('relationship', 'getcount', array('contact_id_a' => $individualID, 'contact_id_b' => $this->_contactID));
+ $this->callAPISuccess('relationship', 'getcount', array(
+ 'contact_id_a' => $individualID,
+ 'contact_id_b' => $this->_contactID
+ ));
}
/**
$this->callAPISuccessGetCount('relationship', array('contact_id_a' => $individualID), 2);
$this->markTestIncomplete('Remainder of test checks that employer relationship is disabled when new one is created but turns out to be not happening - by design?');
$this->callAPISuccessGetCount('relationship', array('contact_id_a' => $individualID, 'is_active' => FALSE), 1);
- $this->callAPISuccessGetCount('relationship', array('contact_id_a' => $individualID, 'is_active' => TRUE, 'contact_id_b' => $organisation2ID), 1);
+ $this->callAPISuccessGetCount('relationship', array(
+ 'contact_id_a' => $individualID,
+ 'is_active' => TRUE,
+ 'contact_id_b' => $organisation2ID
+ ), 1);
}
$result = $this->callAPISuccess('address', 'create', $params);
unset($params['is_primary']);
$params['id'] = $result['id'];
- $result = $this->callAPISuccess('address', 'create', $params);
+ $result = $this->callAPISuccess('address', 'create', $params);
$this->callAPISuccess('address', 'get', array('contact_id' => $params['contact_id']));
$this->assertEquals(1, $result['count']);
$this->assertEquals(1, $result['values'][$result['id']]['is_primary']);
$result = $this->callAPIAndDocument('address', 'delete', array('id' => $create['id']), __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$get = $this->callAPISuccess('address', 'get', array(
- 'location_type_id' => $this->_locationType->id,
+ 'location_type_id' => $this->_locationType->id,
));
$this->assertEquals(0, $get['count'], 'Contact not successfully deleted In line ' . __LINE__);
}
public function testGetAddressSort() {
$create = $this->callAPISuccess('address', 'create', $this->_params);
$this->callAPISuccess('address', 'create', array_merge($this->_params, array('street_address' => 'yzy')));
- $subfile = "AddressSort";
+ $subfile = "AddressSort";
$description = "Demonstrates Use of sort filter";
- $params = array(
+ $params = array(
'options' => array(
'sort' => 'street_address DESC',
'limit' => 2,
*/
public function testGetAddressLikeSuccess() {
$this->callAPISuccess('address', 'create', $this->_params);
- $subfile = "AddressLike";
+ $subfile = "AddressLike";
$description = "Demonstrates Use of Like";
- $params = array(
- 'street_address' => array('LIKE' => '%mb%'),
+ $params = array(
+ 'street_address' => array('LIKE' => '%mb%'),
'sequential' => 1,
);
$result = $this->callAPIAndDocument('Address', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
*/
public function testGetAddressLikeFail() {
$create = $this->callAPISuccess('address', 'create', $this->_params);
- $params = array(
+ $params = array(
'street_address' => array('LIKE' => "'%xy%'"),
'sequential' => 1,
);
$this->assertApiSuccess($address1, 'In line ' . __LINE__);
//now we check & make sure it has been set to primary
$check = $this->callAPISuccess('address', 'getcount', array(
- 'is_primary' => 1,
- 'id' => $address1['id'],
- ));
+ 'is_primary' => 1,
+ 'id' => $address1['id'],
+ ));
$this->assertEquals(1, $check);
$this->callAPISuccess('address', 'delete', array('id' => $address1['id']));
}
$address1 = $this->callAPISuccess('address', 'create', $this->_params);
$this->callAPISuccess('address', 'create', $this->_params);
$check = $this->callAPISuccess('address', 'getcount', array(
- 'is_primary' => 1,
- 'contact_id' => $this->_contactID,
- ));
+ 'is_primary' => 1,
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertEquals(1, $check);
$this->callAPISuccess('address', 'delete', array('id' => $address1['id']));
}
* @package CiviCRM_APIv3
* @subpackage API_Contact
*/
-
class api_v3_ContactTest extends CiviUnitTestCase {
public $DBResetRequired = FALSE;
protected $_apiversion;
'contact_type' => 'Individual',
'last_name' => 'test xyz',
'contact_sub_type' => array('Student', 'Staff'),
- );
+ );
$contact = $this->callAPISuccess('contact', 'create', $params);
$cid = $contact['id'];
$contact = $this->callAPISuccess('contact', 'create', $params);
$this->assertEquals(1, $contact['id']);
}
+
/**
* Verify that attempt to create organization contact without organization name fails
*/
);
$this->callAPIFailure('contact', 'create', $params);
}
+
/**
* Check with complete array + custom field
* Note that the test is written on purpose without any
$description = "/*this demonstrates setting a custom field through the API ";
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description);
- $check = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id']));
+ $check = $this->callAPISuccess($this->_entity, 'get', array(
+ 'return.custom_' . $ids['custom_field_id'] => 1,
+ 'id' => $result['id']
+ ));
$this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']]);
$this->customFieldDelete($ids['custom_field_id']);
/*
* Test creating a current employer through API
*/
- public function testContactCreateCurrentEmployer(){
+ public function testContactCreateCurrentEmployer() {
//here we will just do the get for set-up purposes
$count = $this->callAPISuccess('contact', 'getcount', array(
'organization_name' => 'new employer org',
));
$this->assertEquals(0, $count);
$employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array(
- 'current_employer' => 'new employer org',)
+ 'current_employer' => 'new employer org',
+ )
));
// do it again as an update to check it doesn't cause an error
$employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array(
'current_employer' => 'new employer org',
- 'id' => $employerResult['id'])
+ 'id' => $employerResult['id']
+ )
));
$expectedCount = 1;
$this->callAPISuccess('contact', 'getcount', array(
- 'organization_name' => 'new employer org',
- 'contact_type' => 'Organization'
- ),
- $expectedCount);
+ 'organization_name' => 'new employer org',
+ 'contact_type' => 'Organization'
+ ),
+ $expectedCount);
$result = $this->callAPISuccess('contact', 'getsingle', array(
'id' => $employerResult['id'],
$this->assertEquals('new employer org', $result['current_employer']);
}
+
/*
* Test creating a current employer through API
* - check it will re-activate a de-activated employer
*/
- public function testContactCreateDuplicateCurrentEmployerEnables(){
+ public function testContactCreateDuplicateCurrentEmployerEnables() {
//set up - create employer relationship
$employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array(
- 'current_employer' => 'new employer org',)
+ 'current_employer' => 'new employer org',
+ )
));
$relationship = $this->callAPISuccess('relationship', 'get', array(
'contact_id_a' => $employerResult['id'],
//re-set the current employer - thus enabling the relationshp
$this->callAPISuccess('contact', 'create', array_merge($this->_params, array(
'current_employer' => 'new employer org',
- 'id' => $employerResult['id'])
+ 'id' => $employerResult['id']
+ )
));
//check is_active is now 1
$relationship = $this->callAPISuccess('relationship', 'getsingle', array(
- 'return' => 'is_active',));
+ 'return' => 'is_active',
+ ));
$this->assertEquals(1, $relationship['is_active']);
}
*/
public function testGetDeceasedRetrieved() {
$this->callAPISuccess($this->_entity, 'create', $this->_params);
- $c2 = $this->callAPISuccess($this->_entity, 'create', array('first_name' => 'bb', 'last_name' => 'ccc', 'contact_type' => 'Individual', 'is_deceased' => 1));
+ $c2 = $this->callAPISuccess($this->_entity, 'create', array(
+ 'first_name' => 'bb',
+ 'last_name' => 'ccc',
+ 'contact_type' => 'Individual',
+ 'is_deceased' => 1
+ ));
$result = $this->callAPISuccess($this->_entity, 'get', array('is_deceased' => 0));
$this->assertFalse(array_key_exists($c2['id'], $result['values']));
}
*/
public function testGetSort() {
$c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params);
- $c2 = $this->callAPISuccess($this->_entity, 'create', array('first_name' => 'bb', 'last_name' => 'ccc', 'contact_type' => 'Individual'));
- $result = $this->callAPISuccess($this->_entity, 'get', array(
- 'sort' => 'first_name ASC',
- 'return.first_name' => 1,
- 'sequential' => 1,
- 'rowCount' => 1,
+ $c2 = $this->callAPISuccess($this->_entity, 'create', array(
+ 'first_name' => 'bb',
+ 'last_name' => 'ccc',
+ 'contact_type' => 'Individual'
));
+ $result = $this->callAPISuccess($this->_entity, 'get', array(
+ 'sort' => 'first_name ASC',
+ 'return.first_name' => 1,
+ 'sequential' => 1,
+ 'rowCount' => 1,
+ ));
$this->assertEquals('abc1', $result['values'][0]['first_name']);
$result = $this->callAPISuccess($this->_entity, 'get', array(
$this->callAPISuccess($this->_entity, 'delete', array('id' => $c1['id']));
$this->callAPISuccess($this->_entity, 'delete', array('id' => $c2['id']));
}
+
/*
* Test that we can retrieve contacts using
* 'id' => array('IN' => array('3,4')) syntax
*/
public function testGetINIDArray() {
$c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params);
- $c2 = $this->callAPISuccess($this->_entity, 'create', array('first_name' => 'bb', 'last_name' => 'ccc', 'contact_type' => 'Individual'));
- $c3 = $this->callAPISuccess($this->_entity, 'create', array('first_name' => 'hh', 'last_name' => 'll', 'contact_type' => 'Individual'));
+ $c2 = $this->callAPISuccess($this->_entity, 'create', array(
+ 'first_name' => 'bb',
+ 'last_name' => 'ccc',
+ 'contact_type' => 'Individual'
+ ));
+ $c3 = $this->callAPISuccess($this->_entity, 'create', array(
+ 'first_name' => 'hh',
+ 'last_name' => 'll',
+ 'contact_type' => 'Individual'
+ ));
$result = $this->callAPISuccess($this->_entity, 'get', array('id' => array('IN' => array($c1['id'], $c3['id']))));
$this->assertEquals(2, $result['count']);
$this->assertEquals(array($c1['id'], $c3['id']), array_keys($result['values']));
$this->callAPISuccess($this->_entity, 'delete', array('id' => $c2['id']));
$this->callAPISuccess($this->_entity, 'delete', array('id' => $c3['id']));
}
+
/*
* Test variants on deleted behaviour
*/
$countDefault = $this->callAPISuccess('contact', 'getcount', array());
$countDeleted = $this->callAPISuccess('contact', 'getcount', array(
'contact_is_deleted' => 1,
- ));
+ ));
$countNotDeleted = $this->callAPISuccess('contact', 'getcount', array(
'contact_is_deleted' => 0,
- ));
+ ));
$this->callAPISuccess('contact', 'delete', array('id' => $contact1['id']));
$this->callAPISuccess('contact', 'delete', array('id' => $contact2['id']));
$this->assertEquals(1, $countNotDeleted, 'contact_is_deleted => 0 is respected in line ' . __LINE__);
* Test that sort works - new syntax
*/
public function testGetSortNewSYntax() {
- $c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params);
- $c2 = $this->callAPISuccess($this->_entity, 'create', array('first_name' => 'bb', 'last_name' => 'ccc', 'contact_type' => 'Individual'));
+ $c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params);
+ $c2 = $this->callAPISuccess($this->_entity, 'create', array(
+ 'first_name' => 'bb',
+ 'last_name' => 'ccc',
+ 'contact_type' => 'Individual'
+ ));
$result = $this->callAPISuccess($this->_entity, 'getvalue', array(
'return' => 'first_name',
- 'options' => array(
- 'limit' => 1,
- 'sort' => 'first_name',
- ),
- ));
+ 'options' => array(
+ 'limit' => 1,
+ 'sort' => 'first_name',
+ ),
+ ));
$this->assertEquals('abc1', $result, 'in line' . __LINE__);
$result = $this->callAPISuccess($this->_entity, 'getvalue', array(
- 'return' => 'first_name',
- 'options' => array(
- 'limit' => 1,
- 'sort' => 'first_name DESC',
- ),
- ));
+ 'return' => 'first_name',
+ 'options' => array(
+ 'limit' => 1,
+ 'sort' => 'first_name DESC',
+ ),
+ ));
$this->assertEquals('bb', $result);
$this->callAPISuccess($this->_entity, 'delete', array('id' => $c1['id']));
$subfile = "CustomFieldGet";
$result = $this->callAPISuccess($this->_entity, 'create', $params);
- $check = $this->callAPIAndDocument($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id']), __FUNCTION__, __FILE__, $description, $subfile);
+ $check = $this->callAPIAndDocument($this->_entity, 'get', array(
+ 'return.custom_' . $ids['custom_field_id'] => 1,
+ 'id' => $result['id']
+ ), __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']]);
$fields = ($this->callAPISuccess('contact', 'getfields', $params));
/**
* Check that address name is returned if required
*/
- public function testGetReturnAddressName () {
+ public function testGetReturnAddressName() {
$contactID = $this->individualCreate();
- $this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'address_name' => 'My house', 'location_type_id' => 'Home', 'street_address' => '1 my road'));
- $result = $this->callAPISuccessGetSingle('contact', array('return' => 'address_name, street_address', 'id' => $contactID));
+ $this->callAPISuccess('address', 'create', array(
+ 'contact_id' => $contactID,
+ 'address_name' => 'My house',
+ 'location_type_id' => 'Home',
+ 'street_address' => '1 my road'
+ ));
+ $result = $this->callAPISuccessGetSingle('contact', array(
+ 'return' => 'address_name, street_address',
+ 'id' => $contactID
+ ));
$this->assertEquals('1 my road', $result['street_address']);
$this->assertEquals('My house', $result['address_name']);
}
public function testGetGroupIDFromContact() {
- $groupId = $this->groupCreate();
+ $groupId = $this->groupCreate();
$description = "Get all from group and display contacts";
- $subFile = "GroupFilterUsingContactAPI";
- $params = array(
+ $subFile = "GroupFilterUsingContactAPI";
+ $params = array(
'email' => 'man2@yahoo.com',
'contact_type' => 'Individual',
'location_type_id' => 1,
// testing as string
$params = array(
- 'filter.group_id' => array($groupId, 26),
+ 'filter.group_id' => array($groupId, 26),
'contact_type' => 'Individual',
);
$result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
//test in conjunction with other criteria
$params = array(
- 'filter.group_id' => array($groupId, 26),
+ 'filter.group_id' => array($groupId, 26),
'contact_type' => 'Organization',
);
$this->callAPISuccess('contact', 'get', $params);
$params = array(
- 'filter.group_id' => array(26, 27),
+ 'filter.group_id' => array(26, 27),
'contact_type' => 'Individual',
);
$result = $this->callAPISuccess('contact', 'get', $params);
*/
public function testCreateIndividualWithContributionDottedSyntax() {
$description = "test demonstrates the syntax to create 2 chained entities";
- $subFile = "ChainTwoWebsites";
- $params = array(
+ $subFile = "ChainTwoWebsites";
+ $params = array(
'first_name' => 'abc3',
'last_name' => 'xyz3',
'contact_type' => 'Individual',
'api.contribution.create' => array(
'receive_date' => '2010-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_financialTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'api.contribution.create' => array(
'receive_date' => '2010-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_financialTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
);
$description = "demonstrates creating two websites as an array";
- $subfile = "ChainTwoWebsitesSyntax2";
- $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $subfile = "ChainTwoWebsitesSyntax2";
+ $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals(1, $result['id']);
// the callAndDocument doesn't check the chained call
// delete the contact
$this->callAPISuccess('contact', 'delete', $contact);
}
+
/**
* Verify that attempt to create individual contact with no data fails
*/
);
$this->callAPIFailure('contact', 'create', $params);
}
+
/**
* Verify that attempt to create individual contact with first
* and last names, email and location type succeeds
$employer2 = $this->organizationCreate();
$params = array(
- 'email' => 'man4@yahoo.com',
- 'contact_type' => 'Individual',
- 'employer_id' => $employer,
+ 'email' => 'man4@yahoo.com',
+ 'contact_type' => 'Individual',
+ 'employer_id' => $employer,
);
$result = $this->callAPISuccess('contact', 'create', $params);
$this->callAPISuccess('contact', 'delete', $contact);
}
+
/**
* Verify that attempt to create household contact with inadequate details
* fails
public function testContactDelete() {
$contactID = $this->individualCreate();
$params = array(
- 'id' => $contactID ,
+ 'id' => $contactID,
);
$this->callAPIAndDocument('contact', 'delete', $params, __FUNCTION__, __FILE__);
}
$result = $this->callAPISuccess('contact', 'get', array('birth_date_high' => date('Y-m-d', strtotime('-6 years'))));
$this->assertEquals(1, $result['count']);
$this->assertEquals(date('Y-m-d', strtotime('first day of next month -20 years')), $result['values'][$contact3['id']]['birth_date']);
- $result = $this->callAPISuccess('contact', 'get', array('birth_date_low' => date('Y-m-d', strtotime('-6 years')), 'birth_date_high' => date('Y-m-d', strtotime('- 3 years'))));
+ $result = $this->callAPISuccess('contact', 'get', array(
+ 'birth_date_low' => date('Y-m-d', strtotime('-6 years')),
+ 'birth_date_high' => date('Y-m-d', strtotime('- 3 years'))
+ ));
$this->assertEquals(1, $result['count']);
$this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['birth_date']);
- $result = $this->callAPISuccess('contact', 'get', array('birth_date_low' => '-6 years', 'birth_date_high' => '- 3 years'));
+ $result = $this->callAPISuccess('contact', 'get', array(
+ 'birth_date_low' => '-6 years',
+ 'birth_date_high' => '- 3 years'
+ ));
$this->assertEquals(1, $result['count']);
$this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['birth_date']);
}
$result = $this->callAPISuccess('contact', 'get', array('deceased_date_high' => date('Y-m-d', strtotime('-6 years'))));
$this->assertEquals(1, $result['count']);
$this->assertEquals(date('Y-m-d', strtotime('first day of next month -20 years')), $result['values'][$contact3['id']]['deceased_date']);
- $result = $this->callAPISuccess('contact', 'get', array('deceased_date_low' => '-6 years', 'deceased_date_high' => date('Y-m-d', strtotime('- 3 years'))));
+ $result = $this->callAPISuccess('contact', 'get', array(
+ 'deceased_date_low' => '-6 years',
+ 'deceased_date_high' => date('Y-m-d', strtotime('- 3 years'))
+ ));
$this->assertEquals(1, $result['count']);
$this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['deceased_date']);
}
$this->assertEquals($result[$key], $value);
}
//now we check they are still returned with 'return' key
- $result = $this->callAPISuccess('contact', 'getsingle', array('id' => $contactID, 'return' => array_keys($extraParams)));
+ $result = $this->callAPISuccess('contact', 'getsingle', array(
+ 'id' => $contactID,
+ 'return' => array_keys($extraParams)
+ ));
foreach ($extraParams as $key => $value) {
$this->assertEquals($result[$key], $value);
}
$contactID = $this->householdCreate();
$this->callAPISuccessGetCount('phone', array('contact_id' => $contactID), 0);
$params = array(
- 'contact_id' => $contactID,
- 'household_name' => 'Household 1',
- 'contact_type' => 'Household',
- 'api.phone.create' => array(
+ 'contact_id' => $contactID,
+ 'household_name' => 'Household 1',
+ 'contact_type' => 'Household',
+ 'api.phone.create' => array(
0 => array(
'phone' => '111-111-1111',
'location_type_id' => 1,
$this->callAPISuccessGetCount('phone', array('contact_id' => $contactID), 2);
}
+
/**
* Test for Contact.get id=@user:username (with an invalid username)
*/
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$params['custom_' . $ids['custom_field_id']] = "custom string";
- $moreids = $this->CustomGroupMultipleCreateWithFields();
+ $moreids = $this->CustomGroupMultipleCreateWithFields();
$description = "/*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created ";
- $subfile = "APIChainedArray";
- $params = array(
+ $subfile = "APIChainedArray";
+ $params = array(
'first_name' => 'abc3',
'last_name' => 'xyz3',
'contact_type' => 'Individual',
'api.website.get' => array(),
'api.Contribution.get' => array(
'total_amount' => '120.00',
- ), 'api.CustomValue.get' => 1,
+ ),
+ 'api.CustomValue.get' => 1,
'api.Note.get' => 1,
);
$result = $this->callAPIAndDocument('Contact', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$params['custom_' . $ids['custom_field_id']] = "custom string";
$moreids = $this->CustomGroupMultipleCreateWithFields();
- $andmoreids = $this->CustomGroupMultipleCreateWithFields(array('title' => "another group", 'name' => 'another name'));
+ $andmoreids = $this->CustomGroupMultipleCreateWithFields(array(
+ 'title' => "another group",
+ 'name' => 'another name'
+ ));
$description = "/*this demonstrates the usage of chained api functions. A variety of techniques are used";
$subfile = "APIChainedArrayMultipleCustom";
$params = array(
'api.contribution.create' => array(
'receive_date' => '2010-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'api.contribution.create.1' => array(
'receive_date' => '2011-01-01',
'total_amount' => 120.00,
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
$result = $this->callAPISuccess('Contact', 'create', $params);
$result = $this->callAPISuccess('Contact', 'create', array(
'contact_type' => 'Individual',
- 'id' => $result['id'], 'custom_' .
- $moreids['custom_field_id'][0] => "value 3", 'custom_' .
- $ids['custom_field_id'] => "value 4",
- ));
+ 'id' => $result['id'],
+ 'custom_' .
+ $moreids['custom_field_id'][0] => "value 3",
+ 'custom_' .
+ $ids['custom_field_id'] => "value 4",
+ ));
$params = array(
'id' => $result['id'],
$this->assertEquals(0, $result['values'][$result['id']]['api.CustomValue.get']['is_error']);
$this->assertEquals('http://civicrm.org', $result['values'][$result['id']]['api.website.getValue']);
}
+
/*
* Test checks siusage of $values to pick & choose inputs
*/
$subfile = "APIChainedArrayValuesFromSiblingFunction";
$params = array(
'display_name' => 'batman',
- 'contact_type' => 'Individual',
+ 'contact_type' => 'Individual',
'api.tag.create' => array('name' => '$value.id', 'description' => '$value.display_name', 'format.only_id' => 1),
'api.entity_tag.create' => array('tag_id' => '$value.api.tag.create'),
);
$description = "This demonstrates use of the 'format.is_success' param.
This param causes only the success or otherwise of the function to be returned as BOOLEAN";
$subfile = "FormatIsSuccess_True";
- $params = array('id' => 17, 'format.is_success' => 1);
- $result = $this->callAPIAndDocument('Contact', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $params = array('id' => 17, 'format.is_success' => 1);
+ $result = $this->callAPIAndDocument('Contact', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals(1, $result);
$this->callAPISuccess('Contact', 'Delete', $params);
}
+
/*
* test TrueFalse format
*/
$description = "This demonstrates use of the 'format.is_success' param.
This param causes only the success or otherwise of the function to be returned as BOOLEAN";
$subfile = "FormatIsSuccess_Fail";
- $params = array('id' => 500, 'format.is_success' => 1);
- $result = $this->callAPIAndDocument('Contact', 'Create', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $params = array('id' => 500, 'format.is_success' => 1);
+ $result = $this->callAPIAndDocument('Contact', 'Create', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals(0, $result);
}
+
/*
* test Single Entity format
*/
/* This param causes the only contact to be returned as an array without the other levels.
/* it will be ignored if there is not exactly 1 result";
$subfile = "GetSingleContact";
- $params = array('id' => 17);
- $result = $this->callAPIAndDocument('Contact', 'GetSingle', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $params = array('id' => 17);
+ $result = $this->callAPIAndDocument('Contact', 'GetSingle', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals('Test Contact', $result['display_name']);
$this->callAPISuccess('Contact', 'Delete', $params);
}
$description = "/*This demonstrates use of the 'getCount' action
/* This param causes the count of the only function to be returned as an integer";
$subfile = "GetCountContact";
- $params = array('id' => 17);
- $result = $this->callAPIAndDocument('Contact', 'GetCount', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $params = array('id' => 17);
+ $result = $this->callAPIAndDocument('Contact', 'GetCount', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals('1', $result);
$this->callAPISuccess('Contact', 'Delete', $params);
}
+
/*
* Test id only format
*/
/* This param causes the id of the only entity to be returned as an integer.
/* it will be ignored if there is not exactly 1 result";
$subfile = "FormatOnlyID";
- $params = array('id' => 17, 'format.only_id' => 1);
- $result = $this->callAPIAndDocument('Contact', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $params = array('id' => 17, 'format.only_id' => 1);
+ $result = $this->callAPIAndDocument('Contact', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals('17', $result);
$this->callAPISuccess('Contact', 'Delete', $params);
}
/* This param causes only a single value of the only entity to be returned as an string.
/* it will be ignored if there is not exactly 1 result";
$subFile = "FormatSingleValue";
- $params = array('id' => 17, 'return' => 'display_name');
- $result = $this->callAPIAndDocument('Contact', 'getvalue', $params, __FUNCTION__, __FILE__, $description, $subFile, 'getvalue');
+ $params = array('id' => 17, 'return' => 'display_name');
+ $result = $this->callAPIAndDocument('Contact', 'getvalue', $params, __FUNCTION__, __FILE__, $description, $subFile, 'getvalue');
$this->assertEquals('Test Contact', $result);
$this->callAPISuccess('Contact', 'Delete', $params);
}
public function testContactCreationPermissions() {
$params = array(
'contact_type' => 'Individual',
- 'first_name' => 'Foo',
+ 'first_name' => 'Foo',
'last_name' => 'Bear',
'check_permissions' => TRUE,
);
}
public function testContactUpdatePermissions() {
- $params = array('contact_type' => 'Individual', 'first_name' => 'Foo', 'last_name' => 'Bear', 'check_permissions' => TRUE);
+ $params = array(
+ 'contact_type' => 'Individual',
+ 'first_name' => 'Foo',
+ 'last_name' => 'Bear',
+ 'check_permissions' => TRUE
+ );
$result = $this->callAPISuccess('contact', 'create', $params);
$config = CRM_Core_Config::singleton();
- $params = array('id' => $result['id'], 'contact_type' => 'Individual', 'last_name' => 'Bar', 'check_permissions' => TRUE);
+ $params = array(
+ 'id' => $result['id'],
+ 'contact_type' => 'Individual',
+ 'last_name' => 'Bar',
+ 'check_permissions' => TRUE
+ );
$config->userPermissionClass->permissions = array('access CiviCRM');
$result = $this->callAPIFailure('contact', 'update', $params);
$this->assertEquals('API permission check failed for contact/update call; insufficient permission: require access CiviCRM and edit all contacts', $result['error_message'], 'lacking permissions should not be enough to update a contact');
- $config->userPermissionClass->permissions = array('access CiviCRM', 'add contacts', 'view all contacts', 'edit all contacts', 'import contacts');
+ $config->userPermissionClass->permissions = array(
+ 'access CiviCRM',
+ 'add contacts',
+ 'view all contacts',
+ 'edit all contacts',
+ 'import contacts'
+ );
$this->callAPISuccess('contact', 'update', $params, NULL, 'overfluous permissions should be enough to update a contact');
}
/**
* CRM-14263 check that API is not affected by search profile related bug
*/
- public function testReturnCityProfile () {
+ public function testReturnCityProfile() {
$contactID = $this->individualCreate();
CRM_Core_Config::singleton()->defaultSearchProfileID = 1;
- $this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'city' => 'Cool City', 'location_type_id' => 1));
+ $this->callAPISuccess('address', 'create', array(
+ 'contact_id' => $contactID,
+ 'city' => 'Cool City',
+ 'location_type_id' => 1
+ ));
$result = $this->callAPISuccess('contact', 'get', array('city' => 'Cool City', 'return' => 'contact_type'));
$this->assertEquals(1, $result['count']);
}
$result = $this->callAPISuccess('contact', 'getlist', array('input' => $name));
$this->assertEquals(2, $result['count'], 'In line ' . __LINE__);
// Force-exclude the deceased contact
- $result = $this->callAPISuccess('contact', 'getlist', array('input' => $name, 'params' => array('is_deceased' => 0)));
+ $result = $this->callAPISuccess('contact', 'getlist', array(
+ 'input' => $name,
+ 'params' => array('is_deceased' => 0)
+ ));
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertEquals($contact, $result['values'][0]['id'], 'In line ' . __LINE__);
}
* @package CiviCRM_APIv3
* @subpackage API_Contribution
*/
-
class api_v3_ContributionPageTest extends CiviUnitTestCase {
protected $_apiversion = 3;
protected $testAmount = 34567;
public $DBResetRequired = TRUE;
+
public function setUp() {
parent::setUp();
$this->contactIds[] = $this->individualCreate();
$createResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
$this->id = $createResult['id'];
$getParams = array(
- 'amount' => ''. $this->testAmount, // 3456
+ 'amount' => '' . $this->testAmount, // 3456
'currency' => 'NZD',
'financial_type_id' => 1,
);
$this->callAPISuccess('contribution_page', 'submit', $submitParams);
$this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page']));
}
+
/**
* Test submit with a membership block in place
*/
'payment_processor' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
- 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040 ),
+ 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
'cvv2' => 123,
);
$this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
- $contributions = $this->callAPISuccess('contribution', 'get', array('contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1));
+ $contributions = $this->callAPISuccess('contribution', 'get', array(
+ 'contribution_page_id' => $this->_ids['contribution_page'],
+ 'contribution_status_id' => 1
+ ));
$this->assertCount(2, $contributions['values']);
$membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
$this->assertTrue(in_array($membershipPayment['contribution_id'], array_keys($contributions['values'])));
'payment_processor' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
- 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040 ),
+ 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
'cvv2' => 123,
'is_recur' => 1,
'frequency_interval' => 1,
);
$this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
- $contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1));
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array(
+ 'contribution_page_id' => $this->_ids['contribution_page'],
+ 'contribution_status_id' => 1
+ ));
$membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
$this->assertEquals($membershipPayment['contribution_id'], $contribution['id']);
$membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
$submitParams['contact_id'] = $contribution['contact_id'];
$dummyPP->setDoDirectPaymentResult(array('contribution_status_id' => 1, 'trxn_id' => 'create_second_success'));
$this->callAPISuccess('contribution_page', 'submit', $submitParams);
- $this->callAPISuccess('contribution', 'getsingle', array('id' => array('NOT IN' => array($contribution['id'])), 'contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1));
+ $this->callAPISuccess('contribution', 'getsingle', array(
+ 'id' => array('NOT IN' => array($contribution['id'])),
+ 'contribution_page_id' => $this->_ids['contribution_page'],
+ 'contribution_status_id' => 1
+ ));
$renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
$this->assertEquals(date('Y-m-d', strtotime('+ 1 year', strtotime($membership['end_date']))), $renewedMembership['end_date']);
$recurringContribution = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id']));
'payment_processor' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
- 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040 ),
+ 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
'cvv2' => 123,
'is_recur' => 1,
'frequency_interval' => 1,
);
$this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
- $contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 2));
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array(
+ 'contribution_page_id' => $this->_ids['contribution_page'],
+ 'contribution_status_id' => 2
+ ));
$membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
$this->assertEquals($membershipPayment['contribution_id'], $contribution['id']);
$membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
$this->assertEquals(5, $membership['status_id']);
//@todo - check with Joe about these not existing
//$this->callAPISuccess('line_item', 'getsingle', array('contribution_id' => $contribution['id'], 'entity_id' => $membership['id']));
- $this->callAPISuccess('contribution', 'completetransaction', array('id' => $contribution['id'], 'trxn_id' => 'ipn_called'));
+ $this->callAPISuccess('contribution', 'completetransaction', array(
+ 'id' => $contribution['id'],
+ 'trxn_id' => 'ipn_called'
+ ));
$membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
//renew it with processor setting completed - should extend membership
$submitParams = array_merge($submitParams, array(
- 'contact_id' => $contribution['contact_id'],
- 'is_recur' => 1,
- 'frequency_interval' => 1,
- 'frequency_unit' => 'month',)
+ 'contact_id' => $contribution['contact_id'],
+ 'is_recur' => 1,
+ 'frequency_interval' => 1,
+ 'frequency_unit' => 'month',
+ )
);
$dummyPP->setDoDirectPaymentResult(array('contribution_status_id' => 2));
$this->callAPISuccess('contribution_page', 'submit', $submitParams);
$newContribution = $this->callAPISuccess('contribution', 'getsingle', array(
- 'id' => array(
- 'NOT IN' => array($contribution['id'])), 'contribution_page_id' => $this->_ids['contribution_page'],
- 'contribution_status_id' => 2)
+ 'id' => array(
+ 'NOT IN' => array($contribution['id'])
+ ),
+ 'contribution_page_id' => $this->_ids['contribution_page'],
+ 'contribution_status_id' => 2
+ )
);
$renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
* This function ensures it exists & populates $this->_ids with it's data
*/
public function setUpMembershipBlockPriceSet() {
- $this->_ids['price_set'][] = $this->callAPISuccess('price_set', 'getvalue', array('name' => 'default_membership_type_amount', 'return' => 'id'));
+ $this->_ids['price_set'][] = $this->callAPISuccess('price_set', 'getvalue', array(
+ 'name' => 'default_membership_type_amount',
+ 'return' => 'id'
+ ));
if (empty($this->_ids['membership_type'])) {
$this->_ids['membership_type'] = array($this->membershipTypeCreate(array('minimum_fee' => 2)));
}
$this->_ids['price_set'][] = $priceSet['id'];
}
$priceSetID = reset($this->_ids['price_set']);
- CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID );
+ CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID);
if (empty($this->_ids['price_field'])) {
$priceField = $this->callAPISuccess('price_field', 'create', array(
// put stuff here that should happen before all tests in this unit
}
- public static function tearDownAfterClass(){
+ public static function tearDownAfterClass() {
$tablesToTruncate = array(
'civicrm_contact',
'civicrm_financial_type',
* @package CiviCRM_APIv3
* @subpackage API_Contribution
*/
-
class api_v3_ContributionTest extends CiviUnitTestCase {
/**
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_financialTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 10.00,
'fee_amount' => 5.00,
'net_amount' => 95.00,
'is_allow_other_amount' => 1,
'min_amount' => 10,
'max_amount' => 1000,
- );
+ );
}
public function tearDown() {
$this->assertEquals(2, $contribution['count']);
$this->callAPISuccess('Contribution', 'Delete', array(
- 'id' => $this->_contribution['id'],
+ 'id' => $this->_contribution['id'],
));
$this->callAPISuccess('Contribution', 'Delete', array(
- 'id' => $contribution2['id'],
+ 'id' => $contribution2['id'],
));
}
+
///////////////// civicrm_contribution_
public function testCreateEmptyContributionIDUseDonation() {
$params = array(
'contribution_type_id' => 3,
);
$contribution = $this->callAPISuccess('contribution', 'create', $params);
- $contribution = $this->callAPISuccess('contribution', 'getsingle', array( 'id' => $contribution['id']));
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id']));
$this->assertEquals(3, $contribution['financial_type_id']);
}
* and / or moved to the automated test suite
*/
public function testCreateGetFieldsWithCustom() {
- $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
+ $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$idsContact = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTest.php');
- $result = $this->callAPISuccess('Contribution', 'getfields', array());
+ $result = $this->callAPISuccess('Contribution', 'getfields', array());
$this->assertArrayHasKey('custom_' . $ids['custom_field_id'], $result['values']);
$this->assertArrayNotHasKey('custom_' . $idsContact['custom_field_id'], $result['values']);
$this->customFieldDelete($ids['custom_field_id']);
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_financialTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
));
$this->assertEquals(0, $lineItems['count']);
}
+
/*
* Test checks that passing in line items suppresses the create mechanism
*/
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1 );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345);
$this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF');
'contribution_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
- ));
+ ));
$this->assertEquals(1, $lineItems['count']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['entity_id']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['contribution_id']);
$this->_checkFinancialRecords($contribution, 'offline');
$this->contributionGetnCheck($params, $contribution['id']);
}
+
/**
* Test create with valid payment instument
*/
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']);
- $this->callAPISuccess('contribution', 'create', array('id' => $contribution['id'], 'payment_instrument' => 'Credit Card'));
+ $this->callAPISuccess('contribution', 'create', array(
+ 'id' => $contribution['id'],
+ 'payment_instrument' => 'Credit Card'
+ ));
$contribution = $this->callAPISuccess('contribution', 'get', array(
'sequential' => 1,
'id' => $contribution['id']
$params2 = $this->_params + array('payment_instrument' => 'Cash');
$this->callAPISuccess('contribution', 'create', $params);
$this->callAPISuccess('contribution', 'create', $params2);
- $contribution = $this->callAPISuccess('contribution', 'get', array( 'sequential' => 1, 'contribution_payment_instrument_id' => 'Cash'));
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'sequential' => 1,
+ 'contribution_payment_instrument_id' => 'Cash'
+ ));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('Cash', $contribution['values'][0]['payment_instrument']);
$this->assertEquals(1, $contribution['count']);
- $contribution = $this->callAPISuccess('contribution', 'get', array('sequential' => 1, 'payment_instrument_id' => 'EFT'));
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'sequential' => 1,
+ 'payment_instrument_id' => 'EFT'
+ ));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']);
$this->assertEquals(1, $contribution['count']);
- $contribution = $this->callAPISuccess('contribution', 'get', array( 'sequential' => 1, 'payment_instrument_id' => 5));
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'sequential' => 1,
+ 'payment_instrument_id' => 5
+ ));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']);
$this->assertEquals(1, $contribution['count']);
- $contribution = $this->callAPISuccess('contribution', 'get', array( 'sequential' => 1, 'payment_instrument' => 'EFT'));
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'sequential' => 1,
+ 'payment_instrument' => 'EFT'
+ ));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']);
$this->assertEquals(1, $contribution['count']);
- $contribution = $this->callAPISuccess('contribution', 'create', array('id' => $contribution['id'], 'payment_instrument' => 'Credit Card'));
- $contribution = $this->callAPISuccess('contribution', 'get', array( 'sequential' => 1, 'id' => $contribution['id'] ));
+ $contribution = $this->callAPISuccess('contribution', 'create', array(
+ 'id' => $contribution['id'],
+ 'payment_instrument' => 'Credit Card'
+ ));
+ $contribution = $this->callAPISuccess('contribution', 'get', array('sequential' => 1, 'id' => $contribution['id']));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('Credit Card', $contribution['values'][0]['payment_instrument']);
$this->assertEquals(1, $contribution['count']);
*/
public function testCreateContributionWithNote() {
$description = "Demonstrates creating contribution with Note Entity";
- $subfile = "ContributionCreateWithNote";
- $params = array(
+ $subfile = "ContributionCreateWithNote";
+ $params = array(
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
'total_amount' => 100.00,
);
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
- $result = $this->callAPISuccess('note', 'get', array('entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'sequential' => 1));
+ $result = $this->callAPISuccess('note', 'get', array(
+ 'entity_table' => 'civicrm_contribution',
+ 'entity_id' => $contribution['id'],
+ 'sequential' => 1
+ ));
$this->assertEquals('my contribution note', $result['values'][0]['note']);
$this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id']));
}
public function testCreateContributionWithNoteUniqueNameAliases() {
- $params = array(
+ $params = array(
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
'total_amount' => 100.00,
);
$contribution = $this->callAPISuccess('contribution', 'create', $params);
- $result = $this->callAPISuccess('note', 'get', array('entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'sequential' => 1));
+ $result = $this->callAPISuccess('note', 'get', array(
+ 'entity_table' => 'civicrm_contribution',
+ 'entity_id' => $contribution['id'],
+ 'sequential' => 1
+ ));
$this->assertEquals('my contribution note', $result['values'][0]['note']);
$this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id']));
}
*/
public function testCreateContributionWithSoftCredt() {
$description = "Demonstrates creating contribution with SoftCredit";
- $subfile = "ContributionCreateWithSoftCredit";
- $contact2 = $this->callAPISuccess('Contact', 'create', array('display_name' => 'superman', 'contact_type' => 'Individual'));
- $softparams = array(
+ $subfile = "ContributionCreateWithSoftCredit";
+ $contact2 = $this->callAPISuccess('Contact', 'create', array(
+ 'display_name' => 'superman',
+ 'contact_type' => 'Individual'
+ ));
+ $softparams = array(
'contact_id' => $contact2['id'],
'amount' => 50,
'soft_credit_type_id' => 3
);
- $params = $this->_params + array('soft_credit' => array(1 => $softparams));
+ $params = $this->_params + array('soft_credit' => array(1 => $softparams));
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
$result = $this->callAPISuccess('contribution', 'get', array('return' => 'soft_credit', 'sequential' => 1));
public function testCreateContributionWithSoftCreditDefaults() {
$description = "Demonstrates creating contribution with Soft Credit defaults for amount and type";
- $subfile = "ContributionCreateWithSoftCreditDefaults";
- $contact2 = $this->callAPISuccess('Contact', 'create', array('display_name' => 'superman', 'contact_type' => 'Individual'));
+ $subfile = "ContributionCreateWithSoftCreditDefaults";
+ $contact2 = $this->callAPISuccess('Contact', 'create', array(
+ 'display_name' => 'superman',
+ 'contact_type' => 'Individual'
+ ));
$params = $this->_params + array(
- 'soft_credit_to' => $contact2['id'],
- );
+ 'soft_credit_to' => $contact2['id'],
+ );
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
$result = $this->callAPISuccess('contribution', 'get', array('return' => 'soft_credit', 'sequential' => 1));
public function testCreateContributionWithHonoreeContact() {
$description = "Demonstrates creating contribution with Soft Credit by passing in honor_contact_id";
- $subfile = "ContributionCreateWithHonoreeContact";
- $contact2 = $this->callAPISuccess('Contact', 'create', array('display_name' => 'superman', 'contact_type' => 'Individual'));
+ $subfile = "ContributionCreateWithHonoreeContact";
+ $contact2 = $this->callAPISuccess('Contact', 'create', array(
+ 'display_name' => 'superman',
+ 'contact_type' => 'Individual'
+ ));
$params = $this->_params + array(
- 'honor_contact_id' => $contact2['id'],
- );
+ 'honor_contact_id' => $contact2['id'],
+ );
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
$result = $this->callAPISuccess('contribution', 'get', array('return' => 'soft_credit', 'sequential' => 1));
$page = $this->callAPISuccess('contribution_page', 'create', $this->_pageParams);
$this->assertAPISuccess($page);
require_once 'api/v3/examples/Contribution/Create.php';
- $result = contribution_create_example();
+ $result = contribution_create_example();
$this->assertAPISuccess($result);
$contributionId = $result['id'];
$expectedResult = contribution_create_expectedresult();
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
$this->assertEquals($contribution['values'][$contribution['id']]['fee_amount'], 50.00);
$this->assertEquals($contribution['values'][$contribution['id']]['net_amount'], 50.00);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1 );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345);
$this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF');
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
- ));
+ ));
$this->assertEquals(1, $lineItems['count']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['entity_id']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['contribution_id']);
$lineItems = $this->callAPISuccess('line_item', 'get', array(
- 'entity_id' => $contribution['id'],
- 'contribution_id' => $contribution['id'],
- 'entity_table' => 'civicrm_contribution',
- 'sequential' => 1,
+ 'entity_id' => $contribution['id'],
+ 'contribution_id' => $contribution['id'],
+ 'entity_table' => 'civicrm_contribution',
+ 'sequential' => 1,
));
$this->assertEquals(1, $lineItems['count']);
$this->_checkFinancialRecords($contribution, 'feeAmount');
*/
public function testCreateContributionOnline() {
CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
- $contributionPage = $this->callAPISuccess( 'contribution_page', 'create', $this->_pageParams );
+ $contributionPage = $this->callAPISuccess('contribution_page', 'create', $this->_pageParams);
$this->assertAPISuccess($contributionPage);
$params = array(
'contact_id' => $this->_individualId,
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1 );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345);
$this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF');
public function testCreateContributionPayLaterOnline() {
CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
$this->_pageParams['is_pay_later'] = 1;
- $contributionPage = $this->callAPISuccess( 'contribution_page', 'create', $this->_pageParams );
+ $contributionPage = $this->callAPISuccess('contribution_page', 'create', $this->_pageParams);
$this->assertAPISuccess($contributionPage);
$params = array(
'contact_id' => $this->_individualId,
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1 );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345);
$this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF');
*/
public function testCreateContributionPendingOnline() {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
- $contributionPage = $this->callAPISuccess( 'contribution_page', 'create', $this->_pageParams );
+ $contributionPage = $this->callAPISuccess('contribution_page', 'create', $this->_pageParams);
$this->assertAPISuccess($contributionPage);
$params = array(
'contact_id' => $this->_individualId,
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1 );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345);
$this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF');
public function testCreateBAODefaults() {
unset($this->_params['contribution_source_id'], $this->_params['payment_instrument_id']);
$contribution = $this->callAPISuccess('contribution', 'create', $this->_params);
- $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id'], 'api.contribution.delete' => 1));
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array(
+ 'id' => $contribution['id'],
+ 'api.contribution.delete' => 1
+ ));
$this->assertEquals(1, $contribution['contribution_status_id']);
$this->assertEquals('Check', $contribution['payment_instrument']);
}
$newParams = array(
'id' => $contribution['id'],
- 'total_amount' => '125');
+ 'total_amount' => '125'
+ );
$contribution = $this->callAPISuccess('contribution', 'create', $newParams);
$lineItems = $this->callAPISuccess('line_item', 'getvalue', array(
- 'entity_id' => $contribution['id'],
- 'entity_table' => 'civicrm_contribution',
- 'sequential' => 1,
- 'return' => 'line_total',
+ 'entity_id' => $contribution['id'],
+ 'entity_table' => 'civicrm_contribution',
+ 'sequential' => 1,
+ 'return' => 'line_total',
));
$this->assertEquals('125.00', $lineItems);
$contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
- 'id' => $contribution['id'],
- 'contribution_status_id' => 1,)
+ 'id' => $contribution['id'],
+ 'contribution_status_id' => 1,
+ )
);
$contribution = $this->callAPISuccess('contribution', 'create', $newParams);
$contribution = $contribution['values'][$contribution['id']];
$contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
- 'id' => $contribution['id'],
- 'payment_instrument_id' => $instrumentId,)
+ 'id' => $contribution['id'],
+ 'payment_instrument_id' => $instrumentId,
+ )
);
$contribution = $this->callAPISuccess('contribution', 'create', $newParams);
$this->assertAPISuccess($contribution);
);
$contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
- 'id' => $contribution['id'],
- 'contribution_status_id' => 7,
+ 'id' => $contribution['id'],
+ 'contribution_status_id' => 7,
)
);
);
$contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
- 'id' => $contribution['id'],
- 'contribution_status_id' => 2,
+ 'id' => $contribution['id'],
+ 'contribution_status_id' => 2,
)
);
$this->callAPIFailure('contribution', 'create', $newParams, ts('Cannot change contribution status from Completed to Pending.'));
);
$contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
- 'id' => $contribution['id'],
- 'contribution_status_id' => 3,
+ 'id' => $contribution['id'],
+ 'contribution_status_id' => 3,
)
);
$contribution = $this->callAPISuccess('contribution', 'create', $newParams);
);
$contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
- 'id' => $contribution['id'],
- 'financial_type_id' => 3,
+ 'id' => $contribution['id'],
+ 'financial_type_id' => 3,
)
);
$contribution = $this->callAPISuccess('contribution', 'create', $newParams);
public function testCreateUpdateWithoutChangingPendingStatus() {
$contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_params, array('contribution_status_id' => 2)));
$this->callAPISuccess('contribution', 'create', array('id' => $contribution['id'], 'source' => 'new source'));
- $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id'], 'api.contribution.delete' => 1));
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array(
+ 'id' => $contribution['id'],
+ 'api.contribution.delete' => 1
+ ));
$this->assertEquals(2, $contribution['contribution_status_id']);
}
//To Update Contribution
$this->assertEquals($contribution['values'][$contributionID]['contact_id'], $this->_individualId);
$this->assertEquals($contribution['values'][$contributionID]['total_amount'], 110.00);
- $this->assertEquals($contribution['values'][$contributionID]['financial_type_id'], $this->_financialTypeId );
+ $this->assertEquals($contribution['values'][$contributionID]['financial_type_id'], $this->_financialTypeId);
$this->assertEquals($contribution['values'][$contributionID]['instrument_id'], $old_payment_instrument);
$this->assertEquals($contribution['values'][$contributionID]['non_deductible_amount'], 10.00);
$this->assertEquals($contribution['values'][$contributionID]['fee_amount'], $old_fee_amount);
$this->assertEquals($p['contact_id'], $res['contact_id']);
$this->assertEquals($p['total_amount'], $res['total_amount']);
- $this->assertEquals($p['financial_type_id'], $res['financial_type_id'] );
+ $this->assertEquals($p['financial_type_id'], $res['financial_type_id']);
$this->assertEquals($p['net_amount'], $res['net_amount']);
$this->assertEquals($p['non_deductible_amount'], $res['non_deductible_amount']);
$this->assertEquals($p['fee_amount'], $res['fee_amount']);
$this->assertEquals($p2['contact_id'], $res['contact_id']);
$this->assertEquals($p2['total_amount'], $res['total_amount']);
- $this->assertEquals($p2['financial_type_id'], $res['financial_type_id'] );
+ $this->assertEquals($p2['financial_type_id'], $res['financial_type_id']);
$this->assertEquals($p2['net_amount'], $res['net_amount']);
$this->assertEquals($p2['non_deductible_amount'], $res['non_deductible_amount']);
$this->assertEquals($p2['fee_amount'], $res['fee_amount']);
* that person
*/
public function testCompleteTransaction() {
- $mut = new CiviMailUtils( $this, TRUE );
+ $mut = new CiviMailUtils($this, TRUE);
$this->createLoggedInUser();
$params = array_merge($this->_params, array('contribution_status_id' => 2));
$contribution = $this->callAPISuccess('contribution', 'create', $params);
* tests.
*/
public function testCompleteTransactionWithReceiptDateSet() {
- $mut = new CiviMailUtils( $this, TRUE );
+ $mut = new CiviMailUtils($this, TRUE);
$this->createLoggedInUser();
$params = array_merge($this->_params, array('contribution_status_id' => 2, 'receipt_date' => 'now'));
$contribution = $this->callAPISuccess('contribution', 'create', $params);
* that person
*/
public function testCompleteTransactionWithParticipantRecord() {
- $mut = new CiviMailUtils( $this, TRUE );
+ $mut = new CiviMailUtils($this, TRUE);
$mut->clearMessages();
$this->createLoggedInUser();
$contributionID = $this->createPendingParticipantContribution();
$this->callAPISuccess('contribution', 'completetransaction', array(
- 'id' => $contributionID,)
+ 'id' => $contributionID,
+ )
);
- $participantStatus = $this->callAPISuccessGetValue('participant', array('id' => $this->_ids['participant'], 'return' => 'participant_status_id'));
+ $participantStatus = $this->callAPISuccessGetValue('participant', array(
+ 'id' => $this->_ids['participant'],
+ 'return' => 'participant_status_id'
+ ));
$this->assertEquals(1, $participantStatus);
$mut->checkMailLog(array(
'Annual CiviCRM meet',
));
$priceSetID = $priceSet['id'];
- CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID );
+ CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID);
$priceField = $this->callAPISuccess('price_field', 'create', array(
- 'price_set_id' => $priceSetID ,
+ 'price_set_id' => $priceSetID,
'label' => 'Goat Breed',
'html_type' => 'Radio',
));
$priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array(
- 'price_set_id' => $priceSetID ,
+ 'price_set_id' => $priceSetID,
'price_field_id' => $priceField['id'],
'label' => 'Long Haired Goat',
'amount' => 20,
);
$this->_ids['price_field_value'] = array($priceFieldValue['id']);
$priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array(
- 'price_set_id' => $priceSetID ,
+ 'price_set_id' => $priceSetID,
'price_field_id' => $priceField['id'],
'label' => 'Shoe-eating Goat',
'amount' => 10,
* Set up a pending transaction with a specific price field id
* @param int $priceFieldValueID
*/
- public function setUpPendingContribution($priceFieldValueID){
+ public function setUpPendingContribution($priceFieldValueID) {
$contactID = $this->individualCreate();
$membership = $this->callAPISuccess('membership', 'create', array(
'contact_id' => $contactID,
* Test sending a mail via the API
*/
public function testSendMail() {
- $mut = new CiviMailUtils( $this, TRUE );
+ $mut = new CiviMailUtils($this, TRUE);
$contribution = $this->callAPISuccess('contribution', 'create', $this->_params);
$this->callAPISuccess('contribution', 'sendconfirmation', array(
- 'id' => $contribution['id'],
- 'receipt_from_email' => 'api@civicrm.org',
+ 'id' => $contribution['id'],
+ 'receipt_from_email' => 'api@civicrm.org',
)
);
$mut->checkMailLog(array(
* Test sending a mail via the API
*/
public function testSendMailEvent() {
- $mut = new CiviMailUtils( $this, TRUE );
+ $mut = new CiviMailUtils($this, TRUE);
$contribution = $this->callAPISuccess('contribution', 'create', $this->_params);
$event = $this->eventCreate(array(
'is_email_confirm' => 1,
'contribution_id' => $contribution['id'],
));
$this->callAPISuccess('contribution', 'sendconfirmation', array(
- 'id' => $contribution['id'],
- 'receipt_from_email' => 'api@civicrm.org',
+ 'id' => $contribution['id'],
+ 'receipt_from_email' => 'api@civicrm.org',
)
);
$contribution = $this->callAPISuccess('Contribution', 'Get', array(
'id' => $id,
- ));
+ ));
if ($delete) {
$this->callAPISuccess('contribution', 'delete', array('id' => $id));
* Create a pending contribution & linked pending participant record
* (along with an event)
*/
- public function createPendingParticipantContribution(){
+ public function createPendingParticipantContribution() {
$event = $this->eventCreate(array('is_email_confirm' => 1, 'confirm_from_email' => 'test@civicrm.org'));
$participantID = $this->participantCreate(array('event_id' => $event['id'], 'status_id' => 6));
- $this->_ids['participant'] = $participantID;
+ $this->_ids['participant'] = $participantID;
$params = array_merge($this->_params, array('contribution_status_id' => 2, 'financial_type_id' => 'Event Fee'));
$contribution = $this->callAPISuccess('contribution', 'create', $params);
- $this->callAPISuccess('participant_payment', 'create', array('contribution_id' => $contribution['id'], 'participant_id' => $participantID));
+ $this->callAPISuccess('participant_payment', 'create', array(
+ 'contribution_id' => $contribution['id'],
+ 'participant_id' => $participantID
+ ));
$this->callAPISuccess('line_item', 'get', array(
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
public function _checkFinancialItem($contId, $context) {
if ($context != 'paylater') {
$params = array(
- 'entity_id' => $contId,
- 'entity_table' => 'civicrm_contribution',
+ 'entity_id' => $contId,
+ 'entity_table' => 'civicrm_contribution',
);
$trxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($params, TRUE));
$entityParams = array(
$lineItems = CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution');
foreach ($lineItems as $key => $item) {
$params = array(
- 'entity_id' => $key,
- 'entity_table' => 'civicrm_line_item',
+ 'entity_id' => $key,
+ 'entity_table' => 'civicrm_line_item',
);
$compareParams = array('status_id' => 1);
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $params, $compareParams);
}
elseif ($context == 'refund') {
$compareParams = array(
- 'status_id' => 1,
- 'financial_account_id' => 1,
- 'amount' => -100,
+ 'status_id' => 1,
+ 'financial_account_id' => 1,
+ 'amount' => -100,
);
}
elseif ($context == 'cancelPending') {
$compareParams = array(
- 'status_id' => 3,
- 'financial_account_id' => 1,
- 'amount' => -100,
+ 'status_id' => 3,
+ 'financial_account_id' => 1,
+ 'amount' => -100,
);
}
elseif ($context == 'changeFinancial') {
$lineKey = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
$params = array(
- 'entity_id' => $lineKey,
- 'amount' => -100,
+ 'entity_id' => $lineKey,
+ 'amount' => -100,
);
$compareParams = array(
- 'financial_account_id' => 1,
+ 'financial_account_id' => 1,
);
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $params, $compareParams);
$params = array(
- 'financial_account_id' => 3,
- 'entity_id' => $lineKey,
+ 'financial_account_id' => 3,
+ 'entity_id' => $lineKey,
);
$compareParams = array(
- 'amount' => 100,
+ 'amount' => 100,
);
}
if ($context != 'paylater') {
*/
public function _checkFinancialTrxn($contribution, $context, $instrumentId = NULL) {
$trxnParams = array(
- 'entity_id' => $contribution['id'],
- 'entity_table' => 'civicrm_contribution',
+ 'entity_id' => $contribution['id'],
+ 'entity_table' => 'civicrm_contribution',
);
$trxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($trxnParams, TRUE));
$params = array(
- 'id' => $trxn['financial_trxn_id'],
+ 'id' => $trxn['financial_trxn_id'],
);
if ($context == 'payLater') {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$compareParams = array(
- 'status_id' => 1,
- 'from_financial_account_id' => CRM_Contribute_PseudoConstant::financialAccountType($contribution['financial_type_id'], $relationTypeId),
+ 'status_id' => 1,
+ 'from_financial_account_id' => CRM_Contribute_PseudoConstant::financialAccountType($contribution['financial_type_id'], $relationTypeId),
);
}
elseif ($context == 'refund') {
$compareParams = array(
- 'to_financial_account_id' => 6,
- 'total_amount' => -100,
- 'status_id' => 7,
+ 'to_financial_account_id' => 6,
+ 'total_amount' => -100,
+ 'status_id' => 7,
);
}
elseif ($context == 'cancelPending') {
$compareParams = array(
- 'from_financial_account_id' => 7,
- 'total_amount' => -100,
- 'status_id' => 3,
+ 'from_financial_account_id' => 7,
+ 'total_amount' => -100,
+ 'status_id' => 3,
);
}
elseif ($context == 'changeFinancial' || $context == 'paymentInstrument') {
$entityParams = array(
- 'entity_id' => $contribution['id'],
- 'entity_table' => 'civicrm_contribution',
- 'amount' => -100,
+ 'entity_id' => $contribution['id'],
+ 'entity_table' => 'civicrm_contribution',
+ 'amount' => -100,
);
$trxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams));
$trxnParams1 = array(
'id' => $trxn['financial_trxn_id'],
);
$compareParams = array(
- 'total_amount' => -100,
- 'status_id' => 1,
+ 'total_amount' => -100,
+ 'status_id' => 1,
);
if ($context == 'paymentInstrument') {
$compareParams += array(
- 'to_financial_account_id' => CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount(4),
- 'payment_instrument_id' => 4,
+ 'to_financial_account_id' => CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount(4),
+ 'payment_instrument_id' => 4,
);
}
else {
/**
* @return mixed
*/
- public function _addPaymentInstrument () {
+ public function _addPaymentInstrument() {
$gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'payment_instrument', 'id', 'name');
$optionParams = array(
- 'option_group_id' => $gId,
- 'label' => 'Test Card',
- 'name' => 'Test Card',
- 'value' => '6',
- 'weight' => '6',
- 'is_active' => 1,
+ 'option_group_id' => $gId,
+ 'label' => 'Test Card',
+ 'name' => 'Test Card',
+ 'value' => '6',
+ 'weight' => '6',
+ 'is_active' => 1,
);
$optionValue = $this->callAPISuccess('option_value', 'create', $optionParams);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$financialParams = array(
- 'entity_table' => 'civicrm_option_value',
- 'entity_id' => $optionValue['id'],
- 'account_relationship' => $relationTypeId,
- 'financial_account_id' => 7,
+ 'entity_table' => 'civicrm_option_value',
+ 'entity_id' => $optionValue['id'],
+ 'account_relationship' => $relationTypeId,
+ 'financial_account_id' => 7,
);
CRM_Financial_BAO_FinancialTypeAccount::add($financialParams, CRM_Core_DAO::$_nullArray);
$this->assertNotEmpty($optionValue['values'][$optionValue['id']]['value']);
*/
public function _checkFinancialRecords($params, $context) {
$entityParams = array(
- 'entity_id' => $params['id'],
- 'entity_table' => 'civicrm_contribution',
+ 'entity_id' => $params['id'],
+ 'entity_table' => 'civicrm_contribution',
);
$contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $params['id']));
$this->assertEquals($contribution['total_amount'] - $contribution['fee_amount'], $contribution['net_amount']);
}
$trxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams));
$trxnParams = array(
- 'id' => $trxn['financial_trxn_id'],
+ 'id' => $trxn['financial_trxn_id'],
);
if ($context != 'online' && $context != 'payLater') {
$compareParams = array(
- 'to_financial_account_id' => 6,
- 'total_amount' => 100,
- 'status_id' => 1,
+ 'to_financial_account_id' => 6,
+ 'total_amount' => 100,
+ 'status_id' => 1,
);
}
if ($context == 'feeAmount') {
}
elseif ($context == 'online') {
$compareParams = array(
- 'to_financial_account_id' => 12,
- 'total_amount' => 100,
- 'status_id' => 1,
+ 'to_financial_account_id' => 12,
+ 'total_amount' => 100,
+ 'status_id' => 1,
);
}
elseif ($context == 'payLater') {
$compareParams = array(
- 'to_financial_account_id' => 7,
- 'total_amount' => 100,
- 'status_id' => 2,
+ 'to_financial_account_id' => 7,
+ 'total_amount' => 100,
+ 'status_id' => 2,
);
}
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams, $compareParams);
$entityParams = array(
- 'financial_trxn_id' => $trxn['financial_trxn_id'],
- 'entity_table' => 'civicrm_financial_item',
+ 'financial_trxn_id' => $trxn['financial_trxn_id'],
+ 'entity_table' => 'civicrm_financial_item',
);
$entityTrxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams));
$fitemParams = array(
- 'id' => $entityTrxn['entity_id'],
+ 'id' => $entityTrxn['entity_id'],
);
$compareParams = array(
- 'amount' => 100,
- 'status_id' => 1,
- 'financial_account_id' => 1,
+ 'amount' => 100,
+ 'status_id' => 1,
+ 'financial_account_id' => 1,
);
if ($context == 'payLater') {
$compareParams = array(
- 'amount' => 100,
- 'status_id' => 3,
- 'financial_account_id' => 1,
+ 'amount' => 100,
+ 'status_id' => 3,
+ 'financial_account_id' => 1,
);
}
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams);
if ($context == 'feeAmount') {
$maxParams = array(
- 'entity_id' => $params['id'],
- 'entity_table' => 'civicrm_contribution',
+ 'entity_id' => $params['id'],
+ 'entity_table' => 'civicrm_contribution',
);
$maxTrxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($maxParams, TRUE));
$trxnParams = array(
- 'id' => $maxTrxn['financial_trxn_id'],
+ 'id' => $maxTrxn['financial_trxn_id'],
);
$compareParams = array(
- 'to_financial_account_id' => 5,
- 'from_financial_account_id' => 6,
- 'total_amount' => 50,
- 'status_id' => 1,
+ 'to_financial_account_id' => 5,
+ 'from_financial_account_id' => 6,
+ 'total_amount' => 50,
+ 'status_id' => 1,
);
$trxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['id'], 'DESC');
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams, $compareParams);
$fitemParams = array(
- 'entity_id' => $trxnId['financialTrxnId'],
- 'entity_table' => 'civicrm_financial_trxn',
+ 'entity_id' => $trxnId['financialTrxnId'],
+ 'entity_table' => 'civicrm_financial_trxn',
);
$compareParams = array(
- 'amount' => 50,
- 'status_id' => 1,
- 'financial_account_id' => 5,
+ 'amount' => 50,
+ 'status_id' => 1,
+ 'financial_account_id' => 5,
);
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams);
}
where cleanDB() is called. */
-
public $DBResetRequired = FALSE;
protected $_apiversion = 3;
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$location = array();
$domContact = $this->callAPISuccess('contact', 'create', array(
- 'contact_type' => 'Organization',
- 'organization_name' => 'new org',
- 'api.phone.create' => array(
- 'location_type_id' => $defaultLocationType->id,
- 'phone_type_id' => 1,
- 'phone' => '456-456',
- ),
- 'api.address.create' => array(
- 'location_type_id' => $defaultLocationType->id,
- 'street_address' => '45 Penny Lane',
+ 'contact_type' => 'Organization',
+ 'organization_name' => 'new org',
+ 'api.phone.create' => array(
+ 'location_type_id' => $defaultLocationType->id,
+ 'phone_type_id' => 1,
+ 'phone' => '456-456',
),
- 'api.email.create' => array(
- 'location_type_id' => $defaultLocationType->id,
- 'email' => 'my@email.com',
- )
+ 'api.address.create' => array(
+ 'location_type_id' => $defaultLocationType->id,
+ 'street_address' => '45 Penny Lane',
+ ),
+ 'api.email.create' => array(
+ 'location_type_id' => $defaultLocationType->id,
+ 'email' => 'my@email.com',
+ )
)
);
$this->callAPISuccess('domain', 'create', array(
- 'id' => 1,
- 'contact_id' => $domContact['id'],
+ 'id' => 1,
+ 'contact_id' => $domContact['id'],
)
);
$this->params = array(
*/
-
public function testGetCurrentDomainTwice() {
$domain = $this->callAPISuccess('domain', 'getvalue', array(
- 'current_domain' => 1,
- 'return' => 'name',
- ));
+ 'current_domain' => 1,
+ 'return' => 'name',
+ ));
$this->assertEquals('Default Domain Name', $domain, print_r($domain, TRUE));
$domain = $this->callAPISuccess('domain', 'getvalue', array(
- 'current_domain' => 1,
- 'return' => 'name',
- ));
+ 'current_domain' => 1,
+ 'return' => 'name',
+ ));
$this->assertEquals('Default Domain Name', $domain, print_r($domain, TRUE));
}
$this->_contactID = $this->organizationCreate(NULL);
$this->_locationType = $this->locationTypeCreate(NULL);
$this->_locationType2 = $this->locationTypeCreate(array(
- 'name' => 'New Location Type 2',
- 'vcard_name' => 'New Location Type 2',
- 'description' => 'Another Location Type',
- 'is_active' => 1,
- ));
+ 'name' => 'New Location Type 2',
+ 'vcard_name' => 'New Location Type 2',
+ 'description' => 'Another Location Type',
+ 'is_active' => 1,
+ ));
$this->_params = array(
'contact_id' => $this->_contactID,
'location_type_id' => $this->_locationType->id,
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
$delresult = $this->callAPISuccess('email', 'delete', array('id' => $result['id']));
}
+
/*
* If a new email is set to is_primary the prev should no longer be
*
*/
-
public function testCreateEmailPrimaryHandlingChangeToPrimary() {
$params = $this->_params;
unset($params['is_primary']);
//now we check & make sure it has been set to primary
$expected = 1;
$check = $this->callAPISuccess('email', 'getcount', array(
- 'is_primary' => 1,
- 'id' => $email1['id'],
+ 'is_primary' => 1,
+ 'id' => $email1['id'],
),
$expected
- );
+ );
}
public function testCreateEmailPrimaryHandlingChangeExisting() {
$email1 = $this->callAPISuccess('email', 'create', $this->_params);
$email2 = $this->callAPISuccess('email', 'create', $this->_params);
$check = $this->callAPISuccess('email', 'getcount', array(
- 'is_primary' => 1,
- 'contact_id' => $this->_contactID,
- ));
+ 'is_primary' => 1,
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertEquals(1, $check);
}
$this->assertEquals($get['count'], 1);
$delresult = $this->callAPISuccess('email', 'delete', array('id' => $result['id']));
}
+
public function testDeleteEmail() {
$params = array(
'contact_id' => $this->_contactID,
);
//check there are no emails to start with
$get = $this->callAPISuccess('email', 'get', array(
- 'location_type_id' => $this->_locationType->id,
+ 'location_type_id' => $this->_locationType->id,
));
$this->assertEquals(0, $get['count'], 'email already exists ' . __LINE__);
public function testReplaceEmail() {
// check there are no emails to start with
$get = $this->callAPISuccess('email', 'get', array(
- 'contact_id' => $this->_contactID,
- ));
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertEquals(0, $get['count'], 'email already exists ' . __LINE__);
// initialize email list with three emails at loc #1 and two emails at loc #2
// check emails at location #1 or #2
$get = $this->callAPISuccess('email', 'get', array(
- 'contact_id' => $this->_contactID,
- ));
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertEquals(5, $get['count'], 'Incorrect email count at ' . __LINE__);
// replace the subset of emails in location #1, but preserve location #2
// check emails
$get = $this->callAPISuccess('email', 'get', array(
- 'contact_id' => $this->_contactID,
- ));
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertAPISuccess($get, 'In line ' . __LINE__);
$this->assertEquals(0, $get['count'], 'Incorrect email count at ' . __LINE__);
}
// check there are no emails to start with
$get = $this->callAPISuccess('email', 'get', array(
- 'contact_id' => $this->_contactID,
- ));
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertAPISuccess($get, 'In line ' . __LINE__);
$this->assertEquals(0, $get['count'], 'email already exists ' . __LINE__);
$description = "example demonstrates use of Replace in a nested API call";
// check emails at location #1 or #2
$get = $this->callAPISuccess('email', 'get', array(
- 'contact_id' => $this->_contactID,
- ));
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertEquals(5, $get['count'], 'Incorrect email count at ' . __LINE__);
// replace the subset of emails in location #1, but preserve location #2
public function testReplaceEmailWithId() {
// check there are no emails to start with
$get = $this->callAPISuccess('email', 'get', array(
- 'contact_id' => $this->_contactID,
- ));
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertEquals(0, $get['count'], 'email already exists ' . __LINE__);
// initialize email address
*/
public function testCreateWithoutName() {
$params = array(
- 'is_active' => 1, );
+ 'is_active' => 1,
+ );
$result = $this->callAPIFailure('job', 'create', $params,
'Mandatory key(s) missing from params array: run_frequency, name, api_entity, api_action'
);
*/
public function testDeleteWithIncorrectData() {
$params = array(
- 'id' => 'abcd', );
+ 'id' => 'abcd',
+ );
$result = $this->callAPIFailure('job', 'delete', $params);
}
}
/**
-
- public function testCallUpdateGreetingMissingParams() {
- $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1));
- $this->assertEquals('Mandatory key(s) missing from params array: ct', $result['error_message']);
- }
-
- public function testCallUpdateGreetingIncorrectParams() {
- $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1, 'ct' => 'djkfhdskjfhds'));
- $this->assertEquals('ct `djkfhdskjfhds` is not valid.', $result['error_message']);
- }
- /*
+ *
+ * public function testCallUpdateGreetingMissingParams() {
+ * $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1));
+ * $this->assertEquals('Mandatory key(s) missing from params array: ct', $result['error_message']);
+ * }
+ *
+ * public function testCallUpdateGreetingIncorrectParams() {
+ * $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1, 'ct' => 'djkfhdskjfhds'));
+ * $this->assertEquals('ct `djkfhdskjfhds` is not valid.', $result['error_message']);
+ * }
+ * /*
* Note that this test is about tesing the metadata / calling of the function & doesn't test the success of the called function
*/
public function testCallUpdateGreetingSuccess() {
- $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 'postal_greeting', 'ct' => 'Individual'));
+ $result = $this->callAPISuccess($this->_entity, 'update_greeting', array(
+ 'gt' => 'postal_greeting',
+ 'ct' => 'Individual'
+ ));
}
public function testCallUpdateGreetingCommaSeparatedParamsSuccess() {
$membershipTypeID = $this->membershipTypeCreate();
$this->membershipStatusCreate();
$createTotal = 30;
- for($i = 1; $i <= $createTotal; $i++) {
+ for ($i = 1; $i <= $createTotal; $i++) {
$contactID = $this->individualCreate();
$groupID = $this->groupCreate(array('name' => $i, 'title' => $i));
$result = $this->callAPISuccess('action_schedule', 'create', array(
'group_id' => $groupID,
'limit_to' => FALSE,
));
- $this->callAPISuccess('group_contact', 'create', array('contact_id' => $contactID, 'status' => 'Added', 'group_id' => $groupID));
+ $this->callAPISuccess('group_contact', 'create', array(
+ 'contact_id' => $contactID,
+ 'status' => 'Added',
+ 'group_id' => $groupID
+ ));
}
$result = $this->callAPISuccess('job', 'send_reminder', array());
$successfulCronCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_action_log");
$this->membershipStatusCreate();
$createTotal = 3;
$groupID = $this->groupCreate(array('name' => 'Texan drawlers', 'title' => 'a...'));
- for($i = 1; $i <= $createTotal; $i++) {
+ for ($i = 1; $i <= $createTotal; $i++) {
$contactID = $this->individualCreate();
- if($i == 2) {
+ if ($i == 2) {
$theChosenOneID = $contactID;
}
- if($i < 3) {
- $this->callAPISuccess('group_contact', 'create', array('contact_id' => $contactID, 'status' => 'Added', 'group_id' => $groupID));
+ if ($i < 3) {
+ $this->callAPISuccess('group_contact', 'create', array(
+ 'contact_id' => $contactID,
+ 'status' => 'Added',
+ 'group_id' => $groupID
+ ));
}
- if($i > 1) {
+ if ($i > 1) {
$this->callAPISuccess('membership', 'create', array(
- 'contact_id' => $contactID,
- 'membership_type_id' => $membershipTypeID,
- 'join_date' => '+ 1 hour',
+ 'contact_id' => $contactID,
+ 'membership_type_id' => $membershipTypeID,
+ 'join_date' => '+ 1 hour',
)
);
}
$individualID = $this->individualCreate();
$orgID = $this->organizationCreate();
CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_pre', array($this, 'hookPreRelationship'));
- $relationshipTypeID = $this->callAPISuccess('relationship_type', 'getvalue', array('return' => 'id', 'name_a_b' => 'Employee of'));
+ $relationshipTypeID = $this->callAPISuccess('relationship_type', 'getvalue', array(
+ 'return' => 'id',
+ 'name_a_b' => 'Employee of'
+ ));
$result = $this->callAPISuccess('relationship', 'create', array(
'relationship_type_id' => $relationshipTypeID,
'contact_id_a' => $individualID,
* @param array $params
*/
public function hookPreRelationship($op, $objectName, $id, &$params) {
- if($op == 'delete') {
+ if ($op == 'delete') {
return;
}
- if($params['is_active']) {
+ if ($params['is_active']) {
$params['description'] = 'Hooked';
}
else {
}
public function testDeleteLineItem() {
- $getParams = array( 'entity_table' => 'civicrm_contribution',
+ $getParams = array(
+ 'entity_table' => 'civicrm_contribution',
);
$getResult = $this->callAPISuccess($this->_entity, 'get', $getParams);
$deleteParams = array('id' => $getResult['id']);
$this->_apiversion = 3;
$this->_contactID = $this->individualCreate();
$this->_membershipTypeID = $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID));
- $this->_membershipTypeID2 = $this->membershipTypeCreate(array('period_type' => 'fixed', 'fixed_period_start_day' => '301', 'fixed_period_rollover_day' => '1111'));
+ $this->_membershipTypeID2 = $this->membershipTypeCreate(array(
+ 'period_type' => 'fixed',
+ 'fixed_period_start_day' => '301',
+ 'fixed_period_rollover_day' => '1111'
+ ));
$this->_membershipStatusID = $this->membershipStatusCreate('test status');
CRM_Member_PseudoConstant::membershipType(NULL, TRUE);
public function tearDown() {
$this->quickCleanup(array(
- 'civicrm_membership',
- 'civicrm_membership_payment',
- 'civicrm_membership_log',
+ 'civicrm_membership',
+ 'civicrm_membership_payment',
+ 'civicrm_membership_log',
),
TRUE
);
$result = $membership['values'][$this->_membershipID];
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $this->_membershipID,
- ));
+ ));
$this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__);
$this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__);
$this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
$this->assertEquals(1, $membership['count']);
$this->assertEquals(array($this->_membershipID2), array_keys($membership['values']));
}
+
/**
* Test civicrm_membership_get with params not array.
* Gets treated as contact_id, memberships expected.
$this->assertEquals($result['is_override'], 1, "In line " . __LINE__);
$this->assertEquals($result['id'], $membership['id']);
}
+
/**
* Test civicrm_membership_get with params not array.
* Gets treated as contact_id, memberships expected.
$this->assertEquals($result['contact_id'], $this->_contactID);
$this->assertEquals($result['membership_type_id'], $this->_membershipTypeID2);
}
+
/**
* Check with complete array + custom field
* Note that the test is written on purpose without any
* Memberships expected.
*/
public function testGetOnlyActive() {
- $description = "Demonstrates use of 'filter' active_only' param";
+ $description = "Demonstrates use of 'filter' active_only' param";
$this->_membershipID = $this->contactMembershipCreate($this->_params);
- $subfile = 'filterIsCurrent';
- $params = array(
+ $subfile = 'filterIsCurrent';
+ $params = array(
'contact_id' => $this->_contactID,
'active_only' => 1,
);
'period_type' => 'rolling',
'member_of_contact_id' => $membershipOrgId,
'domain_id' => 1,
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'relationship_type_id' => $relTypeID,
'relationship_direction' => 'b_a',
'is_active' => 1,
$this->assertEquals($this->_membershipStatusID, $membership['status_id']);
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $membership['id'],
- ));
+ ));
$this->membershipTypeDelete(array('id' => $memType['id']));
$this->relationshipTypeDelete($relTypeID);
$this->contactDelete($membershipOrgId);
$this->assertEquals($this->_contactID, $result['values'][$result['id']]['contact_id'], " in line " . __LINE__);
$this->assertEquals($result['id'], $result['values'][$result['id']]['id'], " in line " . __LINE__);
}
+
/*
* Check for useful message if contact doesn't exist
*/
'contact_id is not valid : 999'
);
}
+
public function testMembershipCreateWithInvalidStatus() {
$params = $this->_params;
$params['status_id'] = 999;
$params['custom_' . $ids['custom_field_id']] = "custom string";
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
- $check = $this->callAPISuccess($this->_entity, 'get', array('id' => $result['id'], 'contact_id' => $this->_contactID));
+ $check = $this->callAPISuccess($this->_entity, 'get', array(
+ 'id' => $result['id'],
+ 'contact_id' => $this->_contactID
+ ));
$this->assertEquals("custom string", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
}
$result = $this->callAPISuccess('membership', 'create', $params);
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $result['id'],
- ));
+ ));
$this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
}
$result = $this->callAPISuccess('membership', 'create', $params);
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $result['id'],
- ));
+ ));
$this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
}
'source' => 'changed',
'contact_id' => $this->_contactID,
'status_id' => $this->_membershipStatusID,
- 'membership_type_id' => $this->_membershipTypeID,
+ 'membership_type_id' => $this->_membershipTypeID,
'skipStatusCal' => 1,
);
$result = $this->callAPISuccess('membership', 'create', $params);
$this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $result['id'],
- ));
+ ));
}
/**
$params = $this->_params;
$params['custom_' . $ids['custom_field_id']] = "custom string";
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
- $result = $this->callAPISuccess($this->_entity, 'create', array('id' => $result['id'], 'custom_' . $ids['custom_field_id'] => "new custom"));
- $check = $this->callAPISuccess($this->_entity, 'get', array('id' => $result['id'], 'contact_id' => $this->_contactID));
+ $result = $this->callAPISuccess($this->_entity, 'create', array(
+ 'id' => $result['id'],
+ 'custom_' . $ids['custom_field_id'] => "new custom"
+ ));
+ $check = $this->callAPISuccess($this->_entity, 'get', array(
+ 'id' => $result['id'],
+ 'contact_id' => $this->_contactID
+ ));
$this->assertEquals("new custom", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $check['id'],
- ));
+ ));
$this->customFieldDelete($ids['custom_field_id']);
$this->customGroupDelete($ids['custom_group_id']);
'end_date' => '2008-12-21',
'source' => 'Payment',
'is_override' => 1,
- 'status_id' => $this->_membershipStatusID, );
+ 'status_id' => $this->_membershipStatusID,
+ );
$this->callAPIFailure('membership', 'create', $params);
'id' => $result['id'],
));
}
+
/**
* Test civicrm_contact_memberships_create with membership_contact_id
* membership).
$this->assertEquals('2009-01-21', $result['start_date']);
$this->assertEquals('2009-12-21', $result['end_date']);
}
+
/**
* Test that if membership start date is not set it defaults to correct end date
* - fixed
$this->assertEquals('2009-01-21', $result['start_date']);
$this->assertEquals('2009-12-21', $result['end_date']);
}
+
/**
* Test that if membership end date is not set it defaults to correct end date
* - rolling
$this->assertEquals('2008-03-01', $result['start_date']);
$this->assertEquals('2010-02-28', $result['end_date']);
}
+
/**
* Test that if membership end date is not set it defaults to correct end date
* - rolling
$result = $this->callAPISuccess('option_value', 'get', array(
'option_group_id' => 1,
- 'value' => '1', ));
+ 'value' => '1',
+ ));
$result2 = $this->callAPISuccess('option_value', 'get', array(
'option_group_id' => 1,
- 'value' => '1',
- 'options' => array('offset' => 1),
- ));
+ 'value' => '1',
+ 'options' => array('offset' => 1),
+ ));
$this->assertGreaterThan($result2['count'], $result['count']);
}
*/
public function testGetSingleValueOptionValueSort() {
$description = "demonstrates use of Sort param (available in many api functions). Also, getsingle";
- $subfile = 'SortOption';
- $result = $this->callAPISuccess('option_value', 'getsingle', array(
+ $subfile = 'SortOption';
+ $result = $this->callAPISuccess('option_value', 'getsingle', array(
'option_group_id' => 1,
- 'options' => array(
- 'sort' => 'label ASC',
- 'limit' => 1,
- ),
- ));
+ 'options' => array(
+ 'sort' => 'label ASC',
+ 'limit' => 1,
+ ),
+ ));
$params = array(
'option_group_id' => 1,
- 'options' => array(
+ 'options' => array(
'sort' => 'label DESC',
'limit' => 1,
),
*/
public function testGetValueOptionPagination() {
$pageSize = 10;
- $page1 = $this->callAPISuccess('option_value', 'get', array('options' => array('limit' => $pageSize) ));
+ $page1 = $this->callAPISuccess('option_value', 'get', array('options' => array('limit' => $pageSize)));
$page2 = $this->callAPISuccess('option_value', 'get', array(
'options' => array(
- 'limit' => $pageSize,
- // if you use it for pagination, option.offset=pageSize*pageNumber
- 'offset' => $pageSize - 1,
- ), ));
+ 'limit' => $pageSize,
+ // if you use it for pagination, option.offset=pageSize*pageNumber
+ 'offset' => $pageSize - 1,
+ ),
+ ));
$this->assertEquals($pageSize, $page1['count'], "Check only 10 retrieved in the 1st page " . __LINE__);
$this->assertEquals($pageSize, $page2['count'], "Check only 10 retrieved in the 2nd page " . __LINE__);
'name' => 'from_email_address',
'sequential' => 1,
'api.option_value.create' => array('domain_id' => 2, 'name' => 'my@y.com'),
- ));
+ ));
$optionValueId = $result['values'][0]['api.option_value.create']['id'];
$domain_id = $this->callAPISuccess('option_value', 'getvalue', array(
$result = $this->callAPISuccess('option_group', 'get', array(
'name' => 'from_email_address',
'sequential' => 1,
- 'api.option_value.create' => array('component_id' => 2, 'name' => 'my@y.com'),
+ 'api.option_value.create' => array('component_id' => 2, 'name' => 'my@y.com'),
));
$this->assertAPISuccess($result);
$optionValueId = $result['values'][0]['api.option_value.create']['id'];
$component_id = $this->callAPISuccess('option_value', 'getvalue', array(
'id' => $optionValueId,
- 'return' => 'component_id',
+ 'return' => 'component_id',
));
$this->assertEquals(2, $component_id);
}
$result = $this->callAPISuccess('option_group', 'get', array(
'name' => 'from_email_address',
'sequential' => 1,
- 'api.option_value.create' => array(
+ 'api.option_value.create' => array(
'component_id' => 'CiviContribute',
'name' => 'my@y.com'
- ),
+ ),
));
$this->assertAPISuccess($result);
$optionValueId = $result['values'][0]['api.option_value.create']['id'];
$component_id = $this->callAPISuccess('option_value', 'getvalue', array(
'id' => $optionValueId,
- 'return' => 'component_id',
+ 'return' => 'component_id',
));
$this->assertEquals(2, $component_id);
}
$result = $this->callAPISuccess('option_group', 'get', array(
'name' => 'from_email_address',
'sequential' => 1,
- 'api.option_value.create' => array(
+ 'api.option_value.create' => array(
'component_id' => 'CiviContribute',
- 'name' => 'my@y.com'),
+ 'name' => 'my@y.com'
+ ),
));
$this->assertAPISuccess($result);
$optionValueId = $result['values'][0]['api.option_value.create']['id'];
$component_id = $this->callAPISuccess('option_value', 'getvalue', array(
'id' => $optionValueId,
- 'return' => 'component_id',
+ 'return' => 'component_id',
));
$this->assertEquals(2, $component_id);
}
public function testCRM12133CreateOptionWeightNoValue() {
$optionGroup = $this->callAPISuccess(
'option_group', 'get', array(
- 'name' => 'gender',
- 'sequential' => 1, ));
+ 'name' => 'gender',
+ 'sequential' => 1,
+ ));
$this->assertAPISuccess($optionGroup);
$params = array(
'option_group_id' => $optionGroup['id'],
'label' => 'my@y.com',
- 'weight' => 3,
+ 'weight' => 3,
);
$optionValue = $this->callAPISuccess('option_value', 'create', $params);
$this->assertAPISuccess($optionValue);
$params['weight'] = 4;
- $optionValue2 = $this->callAPISuccess('option_value', 'create', $params );
+ $optionValue2 = $this->callAPISuccess('option_value', 'create', $params);
$this->assertAPISuccess($optionValue2);
$options = $this->callAPISuccess('option_value', 'get', array('option_group_id' => $optionGroup['id']));
$this->assertNotEquals($options['values'][$optionValue['id']]['value'], $options['values'][$optionValue2['id']]['value']);
public function testCreateOptionNoName() {
$optionGroup = $this->callAPISuccess('option_group', 'get', array(
'name' => 'gender',
- 'sequential' => 1, ));
+ 'sequential' => 1,
+ ));
$params = array('option_group_id' => $optionGroup['id'], 'label' => 'my@y.com');
$optionValue = $this->callAPISuccess('option_value', 'create', $params);
*/
public function testCRM11876CreateOptionPseudoConstantUpdated() {
$optionGroupID = $this->callAPISuccess('option_group', 'getvalue', array(
- 'name' => 'payment_instrument',
+ 'name' => 'payment_instrument',
'return' => 'id',
));
$newOption = (string) time();
$res = $this->callAPISuccess('option_value', 'create', array('id' => $ov['id'], 'is_active' => 0));
$val = $this->callAPISuccess('option_value', 'getvalue', array(
'id' => $ov['id'],
- 'return' => 'is_active',
+ 'return' => 'is_active',
));
$this->assertEquals($val, 0, "update with no group id is not proper" . __LINE__);
}
*/
public function testUpdateOptionValueWithGroupId() {
// create a option group
- $og = $this->callAPISuccess('option_group', 'create', array('name' => 'our test Option Group for with group id', 'is_active' => 1));
+ $og = $this->callAPISuccess('option_group', 'create', array(
+ 'name' => 'our test Option Group for with group id',
+ 'is_active' => 1
+ ));
// create a option value
$ov = $this->callAPISuccess('option_value', 'create',
array('option_group_id' => $og['id'], 'label' => 'test option value')
);
// update option value without 'option_group_id'
- $this->callAPISuccess('option_value', 'create', array('id' => $ov['id'], 'option_group_id' => $og['id'], 'is_active' => 0));
+ $this->callAPISuccess('option_value', 'create', array(
+ 'id' => $ov['id'],
+ 'option_group_id' => $og['id'],
+ 'is_active' => 0
+ ));
$val = $this->callAPISuccess('option_value', 'getvalue', array(
'id' => $ov['id'],
- 'return' => 'is_active',
+ 'return' => 'is_active',
));
$this->assertEquals($val, 0, "update with group id is not proper " . __LINE__);
}
parent::setUp();
$this->useTransaction();
- $this->_contactID = $this->organizationCreate();
- $loc = $this->locationTypeCreate();
+ $this->_contactID = $this->organizationCreate();
+ $loc = $this->locationTypeCreate();
$this->_locationType = $loc->id;
CRM_Core_PseudoConstant::flush();
$this->_params = array(
$phone1 = $this->callAPISuccess('phone', 'create', $params);
//now we check & make sure it has been set to primary
$check = $this->callAPISuccess('phone', 'getcount', array(
- 'is_primary' => 1,
- 'id' => $phone1['id'],
- ));
+ 'is_primary' => 1,
+ 'id' => $phone1['id'],
+ ));
$this->assertEquals(1, $check);
}
+
public function testCreatePhonePrimaryHandlingChangeExisting() {
$phone1 = $this->callAPISuccess('phone', 'create', $this->_params);
$phone2 = $this->callAPISuccess('phone', 'create', $this->_params);
<?php
/**
- +--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
+ * +--------------------------------------------------------------------+
+ * | CiviCRM version 4.6 |
+ * +--------------------------------------------------------------------+
+ * | Copyright CiviCRM LLC (c) 2004-2014 |
+ * +--------------------------------------------------------------------+
+ * | This file is a part of CiviCRM. |
+ * | |
+ * | CiviCRM is free software; you can copy, modify, and distribute it |
+ * | under the terms of the GNU Affero General Public License |
+ * | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ * | |
+ * | CiviCRM is distributed in the hope that it will be useful, but |
+ * | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ * | See the GNU Affero General Public License for more details. |
+ * | |
+ * | You should have received a copy of the GNU Affero General Public |
+ * | License and the CiviCRM Licensing Exception along |
+ * | with this program; if not, contact CiviCRM LLC |
+ * | at info[AT]civicrm[DOT]org. If you have questions about the |
+ * | GNU Affero General Public License or the licensing of CiviCRM, |
+ * | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ * +--------------------------------------------------------------------+
*/
require_once 'CiviTest/CiviUnitTestCase.php';
public function setUp() {
parent::setUp();
$this->_cId_a = $this->individualCreate();
- $this->_cId_a_2 = $this->individualCreate(array('last_name' => 'c2', 'email' => 'c@w.com', 'contact_type' => 'Individual'));
+ $this->_cId_a_2 = $this->individualCreate(array(
+ 'last_name' => 'c2',
+ 'email' => 'c@w.com',
+ 'contact_type' => 'Individual'
+ ));
$this->_cId_b = $this->organizationCreate();
$this->_cId_b2 = $this->organizationCreate(array('organization_name' => ' Org 2'));
$this->_entity = 'relationship';
'contact_id_b' => $this->_cId_b,
'relationship_type_id' => $this->_relTypeID,
'start_date' => '2008-12-20',
- 'end_date' => NULL,
+ 'end_date' => NULL,
'is_active' => 1,
);
$relationship = $this->callAPISuccess('relationship', 'create', $params);
}
-
/**
* Check relationship creation
*/
$params['id'] = $result['id'];
$this->callAPISuccess('relationship', 'delete', $params);
}
+
/**
* Ensure disabling works
*/
$this->assertEquals('blah', $result['values'][$result['id']]['description']);
$this->assertEquals(1, $result['values'][$result['id']]['is_permission_b_a']);
}
+
/**
* Check relationship creation
*/
if ($key == 'note') {
continue;
}
- if($key == 'end_date'){
+ if ($key == 'end_date') {
$this->assertTrue(empty($values[$key]));
continue;
}
$rel2Params['end_date'] = 'yesterday';
$rel2 = $this->callAPISuccess('relationship', 'create', $rel2Params);
}
+
/*
* Test using various operators
*/
public function testGetTypeOperators() {
$relTypeParams = array(
- 'name_a_b' => 'Relation 3 for delete',
- 'name_b_a' => 'Relation 6 for delete',
- 'description' => 'Testing relationship type 2',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Organization',
- 'is_reserved' => 1,
- 'is_active' => 1,
+ 'name_a_b' => 'Relation 3 for delete',
+ 'name_b_a' => 'Relation 6 for delete',
+ 'description' => 'Testing relationship type 2',
+ 'contact_type_a' => 'Individual',
+ 'contact_type_b' => 'Organization',
+ 'is_reserved' => 1,
+ 'is_active' => 1,
);
$relationType2 = $this->relationshipTypeCreate($relTypeParams);
$relTypeParams = array(
- 'name_a_b' => 'Relation 8 for delete',
- 'name_b_a' => 'Relation 9 for delete',
- 'description' => 'Testing relationship type 7',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Organization',
- 'is_reserved' => 1,
- 'is_active' => 1,
+ 'name_a_b' => 'Relation 8 for delete',
+ 'name_b_a' => 'Relation 9 for delete',
+ 'description' => 'Testing relationship type 7',
+ 'contact_type_a' => 'Individual',
+ 'contact_type_b' => 'Organization',
+ 'is_reserved' => 1,
+ 'is_active' => 1,
);
$relationType3 = $this->relationshipTypeCreate($relTypeParams);
$relTypeParams = array(
- 'name_a_b' => 'Relation 6 for delete',
- 'name_b_a' => 'Relation 88for delete',
- 'description' => 'Testing relationship type 00',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Organization',
- 'is_reserved' => 1,
- 'is_active' => 1,
+ 'name_a_b' => 'Relation 6 for delete',
+ 'name_b_a' => 'Relation 88for delete',
+ 'description' => 'Testing relationship type 00',
+ 'contact_type_a' => 'Individual',
+ 'contact_type_b' => 'Organization',
+ 'is_reserved' => 1,
+ 'is_active' => 1,
);
$relationType4 = $this->relationshipTypeCreate($relTypeParams);
$rel2 = $this->callAPISuccess('relationship', 'create', array_merge($this->_params,
array('relationship_type_id' => $relationType2)));
$rel3 = $this->callAPISuccess('relationship', 'create', array_merge($this->_params,
- array('relationship_type_id' => $relationType3)));
+ array('relationship_type_id' => $relationType3)));
$rel4 = $this->callAPISuccess('relationship', 'create', array_merge($this->_params,
- array('relationship_type_id' => $relationType4)));
+ array('relationship_type_id' => $relationType4)));
$getParams = array(
'relationship_type_id' => array('IN' => array($relationType2, $relationType3))
$description = "demonstrates use of NOT IN filter";
$subfile = 'NotInRelationshipType';
$getParams = array(
- 'relationship_type_id' => array('NOT IN' => array($relationType2, $relationType3))
+ 'relationship_type_id' => array('NOT IN' => array($relationType2, $relationType3))
);
$result = $this->callAPIAndDocument('relationship', 'get', $getParams, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals($result['count'], 2);
$description = "demonstrates use of BETWEEN filter";
$subfile = 'BetweenRelationshipType';
$getParams = array(
- 'relationship_type_id' => array('BETWEEN' => array($relationType2, $relationType4))
+ 'relationship_type_id' => array('BETWEEN' => array($relationType2, $relationType4))
);
$result = $this->callAPIAndDocument('relationship', 'get', $getParams, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals($result['count'], 3);
$description = "demonstrates use of Not BETWEEN filter";
$subfile = 'NotBetweenRelationshipType';
$getParams = array(
- 'relationship_type_id' => array('NOT BETWEEN' => array($relationType2, $relationType4))
+ 'relationship_type_id' => array('NOT BETWEEN' => array($relationType2, $relationType4))
);
$result = $this->callAPIAndDocument('relationship', 'get', $getParams, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals($result['count'], 1);
$this->AssertEquals(array($rel1['id']), array_keys($result['values']));
}
+
/**
* Check with invalid relationshipType Id
*/
public function testGetRelationshipByTypeDAO() {
$this->ids['relationship'] = $this->callAPISuccess($this->_entity, 'create', array('format.only_id' => TRUE) + $this->_params);
$result = $this->callAPISuccess($this->_entity, 'getcount', array(
- 'contact_id_a' => $this->_cId_a,),
- 1);
+ 'contact_id_a' => $this->_cId_a,
+ ),
+ 1);
$result = $this->callAPISuccess($this->_entity, 'get', array(
'contact_id_a' => $this->_cId_a,
'relationship_type_id' => $this->_relTypeID,
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType2,
- 'contact_id_b' => $this->_cId_b2))
+ 'contact_id_b' => $this->_cId_b2
+ ))
);
//relationshp 3
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType3,
- 'contact_id_b' => $org3))
+ 'contact_id_b' => $org3
+ ))
);
$result = $this->callAPISuccess($this->_entity, 'get', array(
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType2,
- 'contact_id_b' => $this->_cId_b2))
+ 'contact_id_b' => $this->_cId_b2
+ ))
);
//relationshp 3
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType3,
- 'contact_id_b' => $org3))
+ 'contact_id_b' => $org3
+ ))
);
$result = $this->callAPISuccess($this->_entity, 'get', array(
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType2,
- 'contact_id_b' => $this->_cId_b2))
+ 'contact_id_b' => $this->_cId_b2
+ ))
);
//relationshp 3
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType3,
- 'contact_id_b' => $org3))
+ 'contact_id_b' => $org3
+ ))
);
//relationshp 4 with reveral
array_merge($this->_params, array(
'relationship_type_id' => $relType1,
'contact_id_a' => $this->_cId_a,
- 'contact_id_b' => $this->_cId_a_2))
+ 'contact_id_b' => $this->_cId_a_2
+ ))
);
$result = $this->callAPISuccess($this->_entity, 'get', array(
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType2,
- 'contact_id_b' => $this->_cId_b2))
+ 'contact_id_b' => $this->_cId_b2
+ ))
);
//relationshp 3
$this->callAPISuccess($this->_entity, 'create',
array_merge($this->_params, array(
'relationship_type_id' => $relType3,
- 'contact_id_b' => $org3))
+ 'contact_id_b' => $org3
+ ))
);
//relationshp 4 with reveral
array_merge($this->_params, array(
'relationship_type_id' => $relType1,
'contact_id_a' => $this->_cId_a,
- 'contact_id_b' => $this->_cId_a_2))
+ 'contact_id_b' => $this->_cId_a_2
+ ))
);
$result = $this->callAPISuccess($this->_entity, 'get', array(
$params = array(
'name' => 'Default Domain Name',
);
- $result = $this->callAPISuccess( 'domain', 'get', $params);
- if(empty($result['id'])){
- $result = $this->callAPISuccess( 'domain', 'create', $params );
+ $result = $this->callAPISuccess('domain', 'get', $params);
+ if (empty($result['id'])) {
+ $result = $this->callAPISuccess('domain', 'create', $params);
}
$params['name'] = 'Second Domain';
- $result = $this->callAPISuccess( 'domain', 'get', $params);
- if(empty($result['id'])){
- $result = $this->callAPISuccess( 'domain', 'create', $params );
+ $result = $this->callAPISuccess('domain', 'get', $params);
+ if (empty($result['id'])) {
+ $result = $this->callAPISuccess('domain', 'create', $params);
}
$this->_domainID2 = $result['id'];
$params['name'] = 'A-team domain';
- $result = $this->callAPISuccess( 'domain', 'get', $params);
- if(empty($result['id'])){
- $result = $this->callAPISuccess( 'domain', 'create', $params );
+ $result = $this->callAPISuccess('domain', 'get', $params);
+ if (empty($result['id'])) {
+ $result = $this->callAPISuccess('domain', 'create', $params);
}
$this->_domainID3 = $result['id'];
$this->_currentDomain = CRM_Core_Config::domainID();
global $civicrm_root;
$metaDataFolders[] = $civicrm_root . '/tests/phpunit/api/v3/settings';
}
+
/**
- /**
+ * /**
* Check getfields works
*/
public function testGetFields() {
$getResult = $this->callAPISuccess('setting', 'get', $params);
$this->assertEquals(0, $getResult['values'][$this->_currentDomain]['track_civimail_replies']);
$params = array(
- 'domain_id' => $this->_domainID2,
+ 'domain_id' => $this->_domainID2,
'track_civimail_replies' => '1',
);
$result = $this->callAPISuccess('setting', 'create', $params);
public function testGetConfigSetting() {
$settings = $this->callAPISuccess('setting', 'get', array(
'name' => 'defaultCurrency',
- 'sequential' => 1,)
+ 'sequential' => 1,
+ )
);
$this->assertEquals('USD', $settings['values'][0]['defaultCurrency']);
}
public function testGetSetConfigSettingMultipleDomains() {
$settings = $this->callAPISuccess('setting', 'create', array(
'defaultCurrency' => 'USD',
- 'domain_id' => $this->_currentDomain)
+ 'domain_id' => $this->_currentDomain
+ )
);
$settings = $this->callAPISuccess('setting', 'create', array(
'defaultCurrency' => 'CAD',
- 'domain_id' => $this->_domainID2)
+ 'domain_id' => $this->_domainID2
+ )
);
$settings = $this->callAPISuccess('setting', 'get', array(
'return' => 'defaultCurrency',
- 'domain_id' => 'all',
+ 'domain_id' => 'all',
)
);
$this->assertEquals('USD', $settings['values'][$this->_currentDomain]['defaultCurrency']);
*/
public function testGetValueConfigSetting() {
$params = array(
- 'name' => 'monetaryThousandSeparator',
+ 'name' => 'monetaryThousandSeparator',
'group' => 'Localization Setting',
);
$result = $this->callAPISuccess('setting', 'getvalue', $params);
public function testGetValue() {
$params = array(
- 'name' => 'petition_contacts',
+ 'name' => 'petition_contacts',
'group' => 'Campaign Preferences'
);
$description = "Demonstrates getvalue action - intended for runtime use as better caching than get";
*/
public function testRevert() {
$params = array(
- 'address_format' => 'xyz',
+ 'address_format' => 'xyz',
'mailing_format' => 'bcs',
);
$result = $this->callAPISuccess('setting', 'create', $params);
$this->assertAPISuccess($result, "in line " . __LINE__);
$revertParams = array(
- 'name' => 'address_format'
+ 'name' => 'address_format'
);
$result = $this->callAPISuccess('setting', 'get', $params);
//make sure it's set
$result = $this->callAPISuccess('setting', 'get', $params);
$this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']);
$params = array(
- 'return' => array('mailing_format'),
+ 'return' => array('mailing_format'),
);
$result = $this->callAPISuccess('setting', 'get', $params);
//make sure it's unchanged
*/
public function testRevertAll() {
$params = array(
- 'address_format' => 'xyz',
+ 'address_format' => 'xyz',
'mailing_format' => 'bcs',
);
$result = $this->callAPISuccess('setting', 'create', $params);
'name' => 'B Team Domain',
);
$dom = $this->callAPISuccess('domain', 'create', $domparams);
- $params = array( 'domain_id' => 'all',
+ $params = array(
+ 'domain_id' => 'all',
);
$result = $this->callAPISuccess('setting', 'get', $params);
$params = array(
- 'address_format' => 'xyz',
+ 'address_format' => 'xyz',
'mailing_format' => 'bcs',
'domain_id' => $this->_domainID2,
);
$result = $this->callAPISuccess('setting', 'create', $params);
$params = array(
- 'domain_id' => $dom['id'],
+ 'domain_id' => $dom['id'],
);
$result = $this->callAPISuccess('setting', 'get', $params);
$this->assertAPISuccess($result, "in line " . __LINE__);