* Common setup functions for all unit tests
*/
protected function setUp() {
+ $session = CRM_Core_Session::singleton();
+ $session->set('userID', NULL);
+
CRM_Utils_Hook::singleton(TRUE);
$this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // REVERT
// Use a temporary file for STDIN
}
//have a crack @ deleting it first in the hope this will prevent derailing our tests
- $check = $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);
}
* @param string $action - optional action - otherwise taken from function name
*/
function documentMe($params, $result, $function, $filename, $description = "", $subfile = NULL, $action = NULL) {
- if (defined('DONT_DOCUMENT_TEST_CONFIG')) {
+ if (defined('DONT_DOCUMENT_TEST_CONFIG') && DONT_DOCUMENT_TEST_CONFIG) {
return;
}
$entity = substr(basename($filename), 0, strlen(basename($filename)) - 8);
$action = empty($action) ? 'getlist' : $action;
$entityAction = 'GetList';
}
+ elseif (strstr($function, 'GetActions')) {
+ $action = empty($action) ? 'getactions' : $action;
+ $entityAction = 'GetActions';
+ }
elseif (strstr($function, 'Get')) {
$action = empty($action) ? 'get' : $action;
$entityAction = 'Get';
function quickCleanUpFinancialEntities() {
$tablesToTruncate = array(
'civicrm_contribution',
+ 'civicrm_contribution_soft',
'civicrm_financial_trxn',
+ 'civicrm_financial_item',
'civicrm_contribution_recur',
'civicrm_line_item',
'civicrm_contribution_page',
$this->quickCleanup($tablesToTruncate);
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_membership_status WHERE name NOT IN('New', 'Current', 'Grace', 'Expired', 'Pending', 'Cancelled', 'Deceased')");
$this->restoreDefaultPriceSetConfig();
+ $var = TRUE;
+ CRM_Member_BAO_Membership::createRelatedMemberships($var, $var, TRUE);
}
function restoreDefaultPriceSetConfig() {
/**
* Set up an acl allowing contact to see 2 specified groups
- * - $this->_permissionedGroup & $this->_permissionedDisbaledGroup
+ * - $this->_permissionedGroup & $this->_permissionedDisabledGroup
*
- * You need to have precreated these groups & created the user e.g
+ * You need to have pre-created these groups & created the user e.g
* $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'));
return $result['id'];
}
+ /**
+ * Set up initial recurring payment allowing subsequent IPN payments
+ */
+ function setupRecurringPaymentProcessorTransaction() {
+ $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array(
+ 'contact_id' => $this->_contactID,
+ 'amount' => 1000,
+ 'sequential' => 1,
+ 'installments' => 5,
+ 'frequency_unit' => 'Month',
+ 'frequency_interval' => 1,
+ 'invoice_id' => $this->_invoiceID,
+ 'contribution_status_id' => 2,
+ 'processor_id' => $this->_paymentProcessorID,
+ 'api.contribution.create' => array(
+ 'total_amount' => '200',
+ 'invoice_id' => $this->_invoiceID,
+ 'financial_type_id' => 1,
+ 'contribution_status_id' => 'Pending',
+ 'contact_id' => $this->_contactID,
+ 'contribution_page_id' => $this->_contributionPageID,
+ 'payment_processor_id' => $this->_paymentProcessorID,
+ )
+ ));
+ $this->_contributionRecurID = $contributionRecur['id'];
+ $this->_contributionID = $contributionRecur['values']['0']['api.contribution.create']['id'];
+ }
+
+ /**
+ * we don't have a good way to set up a recurring contribution with a membership so let's just do one then alter it
+ */
+ function setupMembershipRecurringPaymentProcessorTransaction() {
+ $this->setupRecurringPaymentProcessorTransaction();
+ $this->ids['membership_type'] = $this->membershipTypeCreate();
+ $this->ids['membership'] = $this->callAPISuccess('membership', 'create', array(
+ 'contact_id' => $this->_contactID,
+ 'membership_type_id' => $this->ids['membership_type'],
+ 'contribution_recur_id' => $this->_contributionRecurID,
+ 'api.membership_payment.create' => array('contribution_id' => $this->_contributionID),
+ 'format.only_id' => TRUE,
+ ));
+ CRM_Core_DAO::executeQuery(
+ "UPDATE civicrm_line_item SET entity_table = 'civicrm_membership', entity_id = {$this->ids['membership']}
+ WHERE entity_id = {$this->_contributionID} AND entity_table = 'civicrm_contribution'"
+ );
+ }
/**
* @param $message
*
* @throws Exception
- */function CiviUnitTestCase_fatalErrorHandler($message) {
- throw new Exception("{$message['message']}: {$message['code']}");
-}
+ */
+ function CiviUnitTestCase_fatalErrorHandler($message) {
+ throw new Exception("{$message['message']}: {$message['code']}");
+ }
}