test fix
authoreileenmcnaughton <eileen@fuzion.co.nz>
Mon, 13 Jul 2015 05:12:40 +0000 (05:12 +0000)
committereileenmcnaughton <eileen@fuzion.co.nz>
Mon, 13 Jul 2015 05:15:24 +0000 (05:15 +0000)
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/ParticipantPaymentTest.php

index dce51b4a5539ab774919ca6d4e3cc632fca12001..ed6ef2548f3cb544579b1d9ee1dbe79bf381c8ac 100755 (executable)
@@ -1649,14 +1649,17 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *   id of created contribution
    */
   public function contributionCreate($params, $cTypeID = 1, $invoiceID = 67890, $trxnID = 12345,
-    $paymentInstrumentID = 1, $isFee = TRUE) {
+    $paymentInstrumentID = 1) {
     if (!is_array($params)) {
       $params = array('contact_id' => $params);
     }
+
     $params = array_merge(array(
       'domain_id' => 1,
       'receive_date' => date('Ymd'),
       'total_amount' => 100.00,
+      'fee_amount' => 5.00,
+      'net_ammount' => 95.00,
       'financial_type_id' => $cTypeID,
       'payment_instrument_id' => empty($paymentInstrumentID) ? 1 : $paymentInstrumentID,
       'non_deductible_amount' => 10.00,
@@ -1666,11 +1669,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       'contribution_status_id' => 1,
     ), $params);
 
-    if ($isFee) {
-      $params['fee_amount'] = 5.00;
-      $params['net_amount'] = 95.00;
-    }
-
     $result = $this->callAPISuccess('contribution', 'create', $params);
     return $result['id'];
   }
index 3aa0e3592147b222117cc5a026fae53583575d4c..7d316767951972dc76610dd0fdafdaddd27ea922 100644 (file)
@@ -1150,7 +1150,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
    */
   public function testCreateUpdateContribution() {
 
-    $contributionID = $this->contributionCreate($this->_individualId, $this->_financialTypeId, 'idofsh', 212355);
+    $contributionID = $this->contributionCreate(array('contact_id' => $this->_individualId), $this->_financialTypeId,
+    'idofsh', 212355);
     $old_params = array(
       'contribution_id' => $contributionID,
 
index 193b030043065c5ddc94a13e3a365f795b0d2141..27cd82b560272f348f84129ddd3bcc2b9e858e95 100644 (file)
@@ -42,7 +42,7 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
   protected $_participantID;
   protected $_eventID;
   protected $_participantPaymentID;
-  protected $_contributionTypeId;
+  protected $_financialTypeId;
 
   public function setUp() {
     parent::setUp();
@@ -52,6 +52,7 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
     $this->_contactID = $this->individualCreate();
     $this->_createdParticipants = array();
     $this->_individualId = $this->individualCreate();
+    $this->_financialTypeId = 1;
 
     $this->_participantID = $this->participantCreate(array(
         'contactID' => $this->_contactID,
@@ -74,14 +75,12 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
       ));
   }
 
-  ///////////////// civicrm_participant_payment_create methods
-
   /**
    * Test civicrm_participant_payment_create with wrong params type.
    */
   public function testPaymentCreateWrongParamsType() {
     $params = 'a string';
-    $result = $this->callAPIFailure('participant_payment', 'create', $params);
+    $this->callAPIFailure('participant_payment', 'create', $params);
   }
 
   /**
@@ -89,7 +88,7 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
    */
   public function testPaymentCreateEmptyParams() {
     $params = array();
-    $result = $this->callAPIFailure('participant_payment', 'create', $params);
+    $this->callAPIFailure('participant_payment', 'create', $params);
   }
 
   /**
@@ -100,8 +99,7 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
     $params = array(
       'participant_id' => $this->_participantID,
     );
-
-    $participantPayment = $this->callAPIFailure('participant_payment', 'create', $params);
+    $this->callAPIFailure('participant_payment', 'create', $params);
   }
 
   /**
@@ -109,7 +107,7 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
    */
   public function testPaymentCreate() {
     //Create Contribution & get contribution ID
-    $contributionID = $this->contributionCreate($this->_contactID);
+    $contributionID = $this->contributionCreate(array('contact_id' => $this->_contactID));
 
     //Create Participant Payment record With Values
     $params = array(
@@ -169,7 +167,13 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
   public function testPaymentOffline() {
 
     // create contribution w/o fee
-    $contributionID = $this->contributionCreate($this->_contactID, $this->_contributionTypeId, NULL, NULL, 4, FALSE);
+    $contributionID = $this->contributionCreate(array(
+      'contact_id' => $this->_contactID,
+      'financial_type_id' => $this->_financialTypeId,
+      'payment_instrument_id' => 4,
+      'fee_amount' => 0,
+      'net_amount' => 100,
+    ));
 
     $this->_participantPaymentID = $this->participantPaymentCreate($this->_participantID, $contributionID);
     $params = array(
@@ -293,27 +297,24 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
    * Check with valid array.
    */
   public function testPaymentDelete() {
-
-    // create contribution
-    $contributionID = $this->contributionCreate($this->_contactID, $this->_contributionTypeId);
+    $contributionID = $this->contributionCreate(array(
+      'contact_id' => $this->_contactID,
+    ));
 
     $this->_participantPaymentID = $this->participantPaymentCreate($this->_participantID, $contributionID);
 
     $params = array(
       'id' => $this->_participantPaymentID,
     );
-
-    $result = $this->callAPIAndDocument('participant_payment', 'delete', $params, __FUNCTION__, __FILE__);
+    $this->callAPIAndDocument('participant_payment', 'delete', $params, __FUNCTION__, __FILE__);
   }
 
-  ///////////////// civicrm_participantPayment_get methods
   /**
    * Test civicrm_participantPayment_get - success expected.
    */
   public function testGet() {
-    //Create Contribution & get contribution ID
-    $contributionID = $this->contributionCreate($this->_contactID3, $this->_contributionTypeId);
-    $participantPaymentID = $this->participantPaymentCreate($this->_participantID4, $contributionID);
+    $contributionID = $this->contributionCreate(array('contact_id' => $this->_contactID3));
+    $this->participantPaymentCreate($this->_participantID4, $contributionID);
 
     //Create Participant Payment record With Values
     $params = array(