test fix, remove old param & fix comments
[civicrm-core.git] / tests / phpunit / api / v3 / ContributionSoftTest.php
index 4c0355666a4b8f04b47c0235ab3be5d5e185074d..fe374aafbd0ab80cfaea83f9cb54417dc42379cc 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -36,7 +36,7 @@ require_once 'CiviTest/CiviUnitTestCase.php';
 class api_v3_ContributionSoftTest extends CiviUnitTestCase {
 
   /**
-   * Assume empty database with just civicrm_data
+   * Assume empty database with just civicrm_data.
    */
   protected $_individualId; //the hard credit contact
   protected $_softIndividual1Id; //the first soft credit contact
@@ -56,7 +56,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     $this->_individualId = $this->individualCreate();
     $this->_softIndividual1Id = $this->individualCreate();
     $this->_softIndividual2Id = $this->individualCreate();
-    $this->_contributionId = $this->contributionCreate($this->_individualId);
+    $this->_contributionId = $this->contributionCreate(array('contact_id' => $this->_individualId));
 
     $paymentProcessor = $this->processorCreate();
     $this->_params = array(
@@ -84,7 +84,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test get methods
+   * Test get methods.
    * @todo - this might be better broken down into more smaller tests
    */
   public function testGetContributionSoft() {
@@ -103,11 +103,11 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     );
     $softcontribution = $this->callAPIAndDocument('contribution_soft', 'get', $params, __FUNCTION__, __FILE__);
     $this->assertEquals(1, $softcontribution['count']);
-    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['contribution_id'], $this->_contributionId, 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['contact_id'], $this->_softIndividual1Id, 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['amount'], '10.00', 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['currency'], 'USD', 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['soft_credit_type_id'], 4, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['contribution_id'], $this->_contributionId);
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['contact_id'], $this->_softIndividual1Id);
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['amount'], '10.00');
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['currency'], 'USD');
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['soft_credit_type_id'], 4);
 
     //create a second soft contribution on the same hard contribution - we are testing that 'id' gets the right soft contribution id (not the contribution id)
     $p['contact_id'] = $this->_softIndividual2Id;
@@ -121,7 +121,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('contribution_soft', 'get', array(
       'id' => $this->_softcontribution['id'],
     ));
-    $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
+    $this->assertEquals(1, $result['count']);
     $this->assertEquals($this->_softcontribution['id'], $result['id']);
     $this->assertEquals($this->_softcontribution['id'], $result['id'], print_r($softcontribution, TRUE));
 
@@ -137,7 +137,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
         'contact_id' => $this->_softIndividual2Id,
       )
     );
-    $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
+    $this->assertEquals(1, $result['count']);
 
     $this->callAPISuccess('contribution_soft', 'Delete', array(
       'id' => $this->_softcontribution['id'],
@@ -156,7 +156,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
 
 
   /**
-   * civicrm_contribution_soft
+   * civicrm_contribution_soft.
    */
   public function testCreateEmptyParamsContributionSoft() {
     $softcontribution = $this->callAPIFailure('contribution_soft', 'create', array(),
@@ -197,7 +197,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
   }
 
   /**
-   * Function tests that additional financial records are created when fee amount is recorded
+   * Function tests that additional financial records are created when fee amount is recorded.
    */
   public function testCreateContributionSoft() {
     $params = array(
@@ -209,15 +209,15 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     );
 
     $softcontribution = $this->callAPIAndDocument('contribution_soft', 'create', $params, __FUNCTION__, __FILE__);
-    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['contribution_id'], $this->_contributionId, 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['contact_id'], $this->_softIndividual1Id, 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['amount'], '10.00', 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['currency'], 'USD', 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['soft_credit_type_id'], 5, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['contribution_id'], $this->_contributionId);
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['contact_id'], $this->_softIndividual1Id);
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['amount'], '10.00');
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['currency'], 'USD');
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['soft_credit_type_id'], 5);
   }
 
   /**
-   * To Update Soft Contribution
+   * To Update Soft Contribution.
    *
    */
   public function testCreateUpdateContributionSoft() {
@@ -238,7 +238,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     );
     $original = $this->callAPISuccess('contribution_soft', 'get', $old_params);
     //Make sure it came back
-    $this->assertEquals($original['id'], $softcontributionID, 'In line ' . __LINE__);
+    $this->assertEquals($original['id'], $softcontributionID);
     //set up list of old params, verify
     $old_contribution_id = $original['values'][$softcontributionID]['contribution_id'];
     $old_contact_id = $original['values'][$softcontributionID]['contact_id'];
@@ -247,11 +247,11 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     $old_soft_credit_type_id = $original['values'][$softcontributionID]['soft_credit_type_id'];
 
     //check against original values
-    $this->assertEquals($old_contribution_id, $this->_contributionId, 'In line ' . __LINE__);
-    $this->assertEquals($old_contact_id, $this->_softIndividual1Id, 'In line ' . __LINE__);
-    $this->assertEquals($old_amount, 10.00, 'In line ' . __LINE__);
-    $this->assertEquals($old_currency, 'USD', 'In line ' . __LINE__);
-    $this->assertEquals($old_soft_credit_type_id, 6, 'In line ' . __LINE__);
+    $this->assertEquals($old_contribution_id, $this->_contributionId);
+    $this->assertEquals($old_contact_id, $this->_softIndividual1Id);
+    $this->assertEquals($old_amount, 10.00);
+    $this->assertEquals($old_currency, 'USD');
+    $this->assertEquals($old_soft_credit_type_id, 6);
     $params = array(
       'id' => $softcontributionID,
       'contribution_id' => $this->_contributionId,
@@ -268,11 +268,11 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     );
     $softcontribution = $this->callAPISuccess('contribution_soft', 'get', $new_params);
     //check against original values
-    $this->assertEquals($softcontribution['values'][$softcontributionID]['contribution_id'], $this->_contributionId, 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontributionID]['contact_id'], $this->_softIndividual1Id, 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontributionID]['amount'], 7.00, 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontributionID]['currency'], 'CAD', 'In line ' . __LINE__);
-    $this->assertEquals($softcontribution['values'][$softcontributionID]['soft_credit_type_id'], 7, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['contribution_id'], $this->_contributionId);
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['contact_id'], $this->_softIndividual1Id);
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['amount'], 7.00);
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['currency'], 'CAD');
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['soft_credit_type_id'], 7);
 
     $params = array(
       'id' => $softcontributionID,
@@ -281,7 +281,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
   }
 
   /**
-   * civicrm_contribution_soft_delete methods
+   * civicrm_contribution_soft_delete methods.
    *
    */
   public function testDeleteEmptyParamsContributionSoft() {
@@ -332,10 +332,10 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     // We're taking the first element.
     $res = $result['values'][$softcontribution['id']];
 
-    $this->assertEquals($p['contribution_id'], $res['contribution_id'], 'In line ' . __LINE__);
-    $this->assertEquals($p['contact_id'], $res['contact_id'], 'In line ' . __LINE__);
-    $this->assertEquals($p['amount'], $res['amount'], 'In line ' . __LINE__);
-    $this->assertEquals($p['currency'], $res['currency'], 'In line ' . __LINE__);
+    $this->assertEquals($p['contribution_id'], $res['contribution_id']);
+    $this->assertEquals($p['contact_id'], $res['contact_id']);
+    $this->assertEquals($p['amount'], $res['amount']);
+    $this->assertEquals($p['currency'], $res['currency']);
   }
 
   /**
@@ -364,10 +364,10 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('contribution_soft', 'get', $params);
     $res = $result['values'][$softcontribution2['id']];
 
-    $this->assertEquals($p2['contribution_id'], $res['contribution_id'], 'In line ' . __LINE__);
-    $this->assertEquals($p2['contact_id'], $res['contact_id'], 'In line ' . __LINE__);
-    $this->assertEquals($p2['amount'], $res['amount'], 'In line ' . __LINE__);
-    $this->assertEquals($p2['currency'], $res['currency'], 'In line ' . __LINE__);
+    $this->assertEquals($p2['contribution_id'], $res['contribution_id']);
+    $this->assertEquals($p2['contact_id'], $res['contact_id']);
+    $this->assertEquals($p2['amount'], $res['amount']);
+    $this->assertEquals($p2['currency'], $res['currency']);
   }
 
 }