CRM-17519 minor fixes to support test expansion
authoreileen <emcnaughton@wikimedia.org>
Wed, 25 Nov 2015 10:16:37 +0000 (23:16 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 25 Nov 2015 11:27:31 +0000 (00:27 +1300)
CRM/Core/Payment/AuthorizeNetIPN.php
tests/phpunit/CiviTest/CiviUnitTestCase.php

index 7f16a6ac581dd0270a12147803ceb3c8b2067f98..7abc07908e1047548bacb7cd8c14cec6a03a872f 100644 (file)
@@ -55,11 +55,11 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
     //we only get invoice num as a key player from payment gateway response.
     //for ARB we get x_subscription_id and x_subscription_paynum
     $x_subscription_id = $this->retrieve('x_subscription_id', 'String');
+    $ids = $objects = $input = array();
 
     if ($x_subscription_id) {
       //Approved
 
-      $ids = $objects = array();
       $input['component'] = $component;
 
       // load post vars in $input
index 7e378a5fbf833d254049118580f0f7d7f384e1ed..631dfc530a2515f7a6449eec75e73baf6a1bf954 100755 (executable)
@@ -3177,8 +3177,8 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
   /**
    * Set up initial recurring payment allowing subsequent IPN payments.
    */
-  public function setupRecurringPaymentProcessorTransaction() {
-    $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array(
+  public function setupRecurringPaymentProcessorTransaction($params = array()) {
+    $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge(array(
       'contact_id' => $this->_contactID,
       'amount' => 1000,
       'sequential' => 1,
@@ -3198,7 +3198,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
         'payment_processor_id' => $this->_paymentProcessorID,
         'is_test' => 0,
       ),
-    ));
+    ), $params));
     $this->_contributionRecurID = $contributionRecur['id'];
     $this->_contributionID = $contributionRecur['values']['0']['api.contribution.create']['id'];
   }
@@ -3209,13 +3209,15 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
   public function setupMembershipRecurringPaymentProcessorTransaction() {
     $this->ids['membership_type'] = $this->membershipTypeCreate();
     //create a contribution so our membership & contribution don't both have id = 1
-    $this->contributionCreate(array(
-      'contact_id' => $this->_contactID,
-      'is_test' => 1,
-      'financial_type_id' => 1,
-      'invoice_id' => 'abcd',
-      'trxn_id' => 345,
-    ));
+    if ($this->callAPISuccess('Contribution', 'getcount', array()) == 0) {
+      $this->contributionCreate(array(
+        'contact_id' => $this->_contactID,
+        'is_test' => 1,
+        'financial_type_id' => 1,
+        'invoice_id' => 'abcd',
+        'trxn_id' => 345,
+      ));
+    }
     $this->setupRecurringPaymentProcessorTransaction();
 
     $this->ids['membership'] = $this->callAPISuccess('membership', 'create', array(
@@ -3239,10 +3241,12 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
       'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', array(
         'return' => 'id',
         'label' => 'Membership Amount',
+        'options' => array('limit' => 1, 'sort' => 'id DESC'),
       )),
       'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', array(
         'return' => 'id',
         'label' => 'General',
+        'options' => array('limit' => 1, 'sort' => 'id DESC'),
       )),
     ));
     $this->callAPISuccess('membership_payment', 'create', array(