From: eileenmcnaugton Date: Fri, 1 Apr 2016 01:58:11 +0000 (+1300) Subject: Update test pledgeCreate function signature X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5210fa35d7dfb5c888ff94013b4792a8848773bf;p=civicrm-core.git Update test pledgeCreate function signature This is more flexible & inline with the signature of similar functions --- diff --git a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php index 21afca3acd..ef6adbe48e 100644 --- a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php @@ -644,7 +644,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { * Set up participant requirements for test. */ public function _setUpPledgeObjects() { - $this->_pledgeId = $this->pledgeCreate($this->_contactId); + $this->_pledgeId = $this->pledgeCreate(array('contact_id' => $this->_contactId)); //we'll create membership payment here because to make setup more re-usable $pledgePayment = $this->callAPISuccess('pledge_payment', 'create', array( 'version' => 3, diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 429a762274..dd1a107c46 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1463,17 +1463,16 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { } /** - * Create contribution. + * Create pledge. * - * @param int $cID - * Contact_id. + * @param array $params + * Parameters. * * @return int - * id of created contribution + * id of created pledge */ - public function pledgeCreate($cID) { - $params = array( - 'contact_id' => $cID, + public function pledgeCreate($params) { + $params = array_merge(array( 'pledge_create_date' => date('Ymd'), 'start_date' => date('Ymd'), 'scheduled_date' => date('Ymd'), @@ -1485,7 +1484,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { 'frequency_unit' => 'year', 'frequency_day' => 15, 'installments' => 5, - ); + ), + $params); $result = $this->callAPISuccess('Pledge', 'create', $params); return $result['id']; diff --git a/tests/phpunit/api/v3/PledgePaymentTest.php b/tests/phpunit/api/v3/PledgePaymentTest.php index 82266c3e19..6d942926a6 100644 --- a/tests/phpunit/api/v3/PledgePaymentTest.php +++ b/tests/phpunit/api/v3/PledgePaymentTest.php @@ -47,7 +47,7 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); $this->_individualId = $this->individualCreate(); - $this->_pledgeID = $this->pledgeCreate($this->_individualId); + $this->_pledgeID = $this->pledgeCreate(array('contact_id' => $this->_individualId)); $this->_contributionID = $this->contributionCreate(array('contact_id' => $this->_individualId)); } diff --git a/tests/phpunit/api/v3/PledgeTest.php b/tests/phpunit/api/v3/PledgeTest.php index 724884b6d4..b1f4dd35ce 100644 --- a/tests/phpunit/api/v3/PledgeTest.php +++ b/tests/phpunit/api/v3/PledgeTest.php @@ -396,7 +396,7 @@ class api_v3_PledgeTest extends CiviUnitTestCase { */ public function testCreateUpdatePledge() { // we test 'sequential' param here too - $pledgeID = $this->pledgeCreate($this->_individualId); + $pledgeID = $this->pledgeCreate(array('contact_id' => $this->_individualId)); $old_params = array( 'id' => $pledgeID, 'sequential' => 1, @@ -443,7 +443,7 @@ class api_v3_PledgeTest extends CiviUnitTestCase { * We test 'sequential' param here too. */ public function testCreateUpdatePledgeLegacy() { - $pledgeID = $this->pledgeCreate($this->_individualId); + $pledgeID = $this->pledgeCreate(array('contact_id' => $this->_individualId)); $old_params = array( 'id' => $pledgeID, 'sequential' => 1, @@ -505,11 +505,11 @@ class api_v3_PledgeTest extends CiviUnitTestCase { */ public function testDeletePledge() { - $pledgeID = $this->pledgeCreate($this->_individualId); + $pledgeID = $this->pledgeCreate(array('contact_id' => $this->_individualId)); $params = array( 'pledge_id' => $pledgeID, ); - $result = $this->callAPIAndDocument('pledge', 'delete', $params, __FUNCTION__, __FILE__); + $this->callAPIAndDocument('pledge', 'delete', $params, __FUNCTION__, __FILE__); } /** @@ -517,7 +517,7 @@ class api_v3_PledgeTest extends CiviUnitTestCase { */ public function testDeletePledgeUseID() { - $pledgeID = $this->pledgeCreate($this->_individualId); + $pledgeID = $this->pledgeCreate(array('contact_id' => $this->_individualId)); $params = array( 'id' => $pledgeID, );