Commit 5896d037 authored by totten's avatar totten
Browse files

INFRA-132 - tests/ - Misc

parent a3e55d9c
......@@ -128,7 +128,8 @@ class CiviDBAssert {
* @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);
......
......@@ -152,8 +152,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
/**
* 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
......@@ -667,7 +667,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
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");
......@@ -684,8 +684,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
/**
* @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
......@@ -1037,32 +1038,33 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
*
* @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);
......@@ -1682,8 +1684,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
* @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;
......@@ -1732,16 +1735,17 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
/**
* 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");
......@@ -1811,7 +1815,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
/**
* Edit Financial Account
*/
function _testEditFinancialAccount($editfinancialAccount,
function _testEditFinancialAccount(
$editfinancialAccount,
$financialAccountTitle = FALSE,
$financialAccountDescription = FALSE,
$accountingCode = FALSE,
......@@ -2096,11 +2101,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
*
* @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
......@@ -2126,7 +2131,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
$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);
......@@ -2146,7 +2151,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
}
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);
}
......@@ -2211,7 +2216,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
$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('');
......@@ -2257,7 +2267,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
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']");
......
......@@ -109,8 +109,9 @@ class CiviTestSuite extends PHPUnit_Framework_TestSuite {
* @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()
......
This diff is collapsed.
......@@ -636,8 +636,9 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
* @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");
......
......@@ -57,7 +57,8 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase {
* saveMappingName : to override mapping name
*
*/
function importCSVComponent($component,
function importCSVComponent(
$component,
$headers,
$rows,
$contactType = 'Individual',
......
......@@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php';
* @package CiviCRM_APIv3
* @subpackage API_Contact
*/
class api_v3_ACLCachingTest extends CiviUnitTestCase {
protected $_apiversion = 3;
protected $_params;
......@@ -44,6 +43,7 @@ class api_v3_ACLCachingTest extends CiviUnitTestCase {
public function setUp() {
parent::setUp();
}
/**
* (non-PHPdoc)
* @see CiviUnitTestCase::tearDown()
......
......@@ -33,7 +33,6 @@ require_once 'CiviTest/CiviUnitTestCase.php';
* @package CiviCRM_APIv3
* @subpackage API_Contact
*/
class api_v3_ACLPermissionTest extends CiviUnitTestCase {
protected $_apiversion = 3;
public $DBResetRequired = FALSE;
......@@ -233,10 +232,19 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
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
......@@ -267,6 +275,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
));
$this->assertEquals(2, $result['count']);
}
/**
* @dataProvider entities
* confirm that with check permissions we don't get entities
......@@ -310,7 +319,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
*/
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',
......
......@@ -47,9 +47,9 @@ class api_v3_ActivityContactTest extends CiviUnitTestCase {
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,
......
......@@ -86,7 +86,7 @@ class api_v3_AddressTest extends CiviUnitTestCase {
'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__);
......@@ -127,7 +127,10 @@ class api_v3_AddressTest extends CiviUnitTestCase {
'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
));
}
/**
......@@ -141,7 +144,10 @@ class api_v3_AddressTest extends CiviUnitTestCase {
'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
));
}
/**
......@@ -163,7 +169,11 @@ class api_v3_AddressTest extends CiviUnitTestCase {
$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);
}
......@@ -178,7 +188,7 @@ class api_v3_AddressTest extends CiviUnitTestCase {
$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']);
......@@ -201,7 +211,7 @@ class api_v3_AddressTest extends CiviUnitTestCase {
$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__);
}
......@@ -242,9 +252,9 @@ class api_v3_AddressTest extends CiviUnitTestCase {
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,
......@@ -262,10 +272,10 @@ class api_v3_AddressTest extends CiviUnitTestCase {
*/
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);
......@@ -279,7 +289,7 @@ class api_v3_AddressTest extends CiviUnitTestCase {
*/
public function testGetAddressLikeFail() {
$create = $this->callAPISuccess('address', 'create', $this->_params);
$params = array(
$params = array(
'street_address' => array('LIKE' => "'%xy%'"),
'sequential' => 1,
);
......@@ -319,9 +329,9 @@ class api_v3_AddressTest extends CiviUnitTestCase {
$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']));
}
......@@ -333,9 +343,9 @@ class api_v3_AddressTest extends CiviUnitTestCase {
$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']));
}
......
This diff is collapsed.
......@@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php';
* @package CiviCRM_APIv3
* @subpackage API_Contribution
*/
class api_v3_ContributionPageTest extends CiviUnitTestCase {
protected $_apiversion = 3;
protected $testAmount = 34567;
......@@ -61,6 +60,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
public $DBResetRequired = TRUE;
public function setUp() {
parent::setUp();
$this->contactIds[] = $this->individualCreate();
......@@ -110,7 +110,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
$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,
);
......@@ -148,6 +148,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
$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
*/
......@@ -238,12 +239,15 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
'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'])));
......@@ -278,7 +282,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
'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,
......@@ -286,7 +290,10 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
);
$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']));
......@@ -299,7 +306,11 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
$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']));
......@@ -333,7 +344,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
'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,
......@@ -341,7 +352,10 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
);
$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']));
......@@ -349,21 +363,28 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
$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']));
......@@ -402,7 +423,10 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
* 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)));