From b6b59c643ef62db70a5df986db14b214bafd760e Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 25 Nov 2015 23:16:37 +1300 Subject: [PATCH] CRM-17519 minor fixes to support test expansion --- CRM/Core/Payment/AuthorizeNetIPN.php | 2 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 24 ++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index 7f16a6ac58..7abc07908e 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -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 diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 7e378a5fbf..631dfc530a 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -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( -- 2.25.1