Merge pull request #5536 from totten/4.5-httpclient
[civicrm-core.git] / tests / phpunit / api / v3 / PledgePaymentTest.php
index 0f308e7044f754271224d4072717765364937330..53210584f383c13df3cf952ba04f9d7e72e2eb3e 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | 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';
 
 /**
  * Test class for Pledge API - civicrm_pledge_*
  *
- *  @package CiviCRM_APIv3
+ * @package CiviCRM_APIv3
  */
-
 class api_v3_PledgePaymentTest extends CiviUnitTestCase {
 
   /**
-   * Assume empty database with just civicrm_data
+   * Assume empty database with just civicrm_data.
    */
   protected $_individualId;
   protected $_pledgeID;
@@ -46,14 +45,14 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
   protected $_entity = 'PledgePayment';
   public $DBResetRequired = TRUE;
 
-  function setUp() {
+  public function setUp() {
     parent::setUp();
     $this->_individualId = $this->individualCreate();
     $this->_pledgeID = $this->pledgeCreate($this->_individualId);
     $this->_contributionID = $this->contributionCreate($this->_individualId);
   }
 
-  function tearDown() {
+  public function tearDown() {
     $tablesToTruncate = array(
       'civicrm_contribution',
       'civicrm_contact',
@@ -65,16 +64,16 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
     $this->quickCleanup($tablesToTruncate);
   }
 
-  function testGetPledgePayment() {
+  public function testGetPledgePayment() {
     $params = array();
     $result = $this->callAPIAndDocument('pledge_payment', 'get', $params, __FUNCTION__, __FILE__);
     $this->assertEquals(5, $result['count'], " in line " . __LINE__);
   }
 
   /**
-   * Test that passing in a single variable works
+   * Test that passing in a single variable works.
    */
-  function testGetSinglePledgePayment() {
+  public function testGetSinglePledgePayment() {
     $createparams = array(
       'contact_id' => $this->_individualId,
       'pledge_id' => $this->_pledgeID,
@@ -92,7 +91,7 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
   /**
    * Test that passing in a single variable works:: status_id
    */
-  function testGetSinglePledgePaymentByStatusID() {
+  public function testGetSinglePledgePaymentByStatusID() {
     $createparams = array(
       'contact_id' => $this->_individualId,
       'pledge_id' => $this->_pledgeID,
@@ -109,9 +108,9 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test that creating a payment will add the contribution ID
+   * Test that creating a payment will add the contribution ID.
    */
-  function testCreatePledgePayment() {
+  public function testCreatePledgePayment() {
     //check that 5 pledge payments exist at the start
     $beforeAdd = $this->callAPISuccess('pledge_payment', 'get', array());
     $this->assertEquals(5, $beforeAdd['count'], " in line " . __LINE__);
@@ -145,7 +144,6 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
     $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams);
     $params['contribution_id'] = $contribution['id'];
 
-
     $resultCont2 = $this->callAPISuccess('pledge_payment', 'create', $params);
     //make sure original is untouched & has not been updated
     $this->assertGreaterThan($result['id'], $resultCont2['id'], " in line " . __LINE__);
@@ -155,9 +153,9 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test checks behaviour when more payments are created than should be possible
+   * Test checks behaviour when more payments are created than should be possible.
    */
-  function testCreatePledgePaymentAllCreated() {
+  public function testCreatePledgePaymentAllCreated() {
     $params = array(
       'pledge_id' => $this->_pledgeID,
       'status_id' => 1,
@@ -190,17 +188,16 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
     $params['scheduled_date'] = '20131212';
     $resultcreatenew = $this->callAPISuccess('pledge_payment', 'create', $params);
     $result = $this->callAPISuccess('PledgePayment', 'Get', array(
-        'pledge_id' => $this->_pledgeID,
-      ));
+      'pledge_id' => $this->_pledgeID,
+    ));
 
     $this->assertEquals(6, $result['count']);
   }
 
   /**
-   * Test that creating a payment will add the contribution ID where only one pledge payment
-   * in schedule
+   * Test that creating a payment adds the contribution ID where only one pledge payment is in schedule.
    */
-  function testCreatePledgePaymentWhereOnlyOnePayment() {
+  public function testCreatePledgePaymentWhereOnlyOnePayment() {
     $pledgeParams = array(
       'contact_id' => $this->_individualId,
       'pledge_create_date' => date('Ymd'),
@@ -233,11 +230,11 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
     //check existing updated not new one created - 'create' means add contribution_id in this context
     $afterAdd = $this->callAPISuccess('pledge_payment', 'get', array(
       'contribution_id' => $contributionID,
-      ));
+    ));
     $this->assertEquals(1, $afterAdd['count'], " in line " . __LINE__);
   }
 
-  function testUpdatePledgePayment() {
+  public function testUpdatePledgePayment() {
     $params = array(
       'pledge_id' => $this->_pledgeID,
       'contribution_id' => $this->_contributionID,
@@ -251,10 +248,10 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
     );
 
     $result = $this->callAPIAndDocument('pledge_payment', 'update', $updateparams, __FUNCTION__, __FILE__);
-    $this->getAndCheck(array_merge($params,$updateparams), $result['id'], $this->_entity);
+    $this->getAndCheck(array_merge($params, $updateparams), $result['id'], $this->_entity);
   }
 
-  function testDeletePledgePayment() {
+  public function testDeletePledgePayment() {
     $params = array(
       'contact_id' => $this->_individualId,
       'pledge_id' => $this->_pledgeID,
@@ -271,9 +268,9 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase {
     $result = $this->callAPIAndDocument('pledge_payment', 'delete', $deleteParams, __FUNCTION__, __FILE__);
   }
 
-  function testGetFields() {
+  public function testGetFields() {
     $result = $this->callAPISuccess('PledgePayment', 'GetFields', array());
     $this->assertType('array', $result);
   }
-}
 
+}