From cc0c30cc0da0429d98ee35936366c1109439aa70 Mon Sep 17 00:00:00 2001 From: Eileen Date: Fri, 3 Jan 2014 18:29:15 +1300 Subject: [PATCH] CRM unit tests - enotice compliance & typos on BaseIPN --- CRM/Core/Payment/BaseIPN.php | 3 ++- tests/phpunit/CRM/Core/Payment/BaseIPNTest.php | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index e6130eded9..eeff13606e 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -57,7 +57,7 @@ class CRM_Core_Payment_BaseIPN { */ function setInputParameters($parameters) { if(!is_array($parameters)) { - throw new CRM_Core_Exceptions('Invalid input parameters'); + throw new CRM_Core_Exception('Invalid input parameters'); } $this->_inputParameters = $parameters; } @@ -142,6 +142,7 @@ class CRM_Core_Payment_BaseIPN { $success = $contribution->loadRelatedObjects($input, $ids, $required); } catch(Exception $e) { + $success = FALSE; if (CRM_Utils_Array::value('log_error', $error_handling)) { CRM_Core_Error::debug_log_message($e->getMessage()); } diff --git a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php index 763b662039..7d3695b284 100644 --- a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php @@ -71,9 +71,14 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { 'user_name' => 'user_name', 'password' => 'password', 'url_recur' => 'url_recur', + //@todo - if we used the api then we could pass in 'AuthNet & the api will resolve + // (as least it will once the pseudoconstant s in the schema) + 'payment_processor_type_id' => $this->callAPISuccess('payment_processor_type', 'getvalue', array( + 'return' => 'id', + 'name' => 'AuthNet' + )), ); - $paymentProcessorParams['payment_processor_type'] = 'AuthorizeNet'; $paymentProcessorParams['domain_id'] = 1; $paymentProcessorParams['is_active'] = 1; $paymentProcessorParams['is_test'] = 1; @@ -122,7 +127,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { 'civicrm_line_item', ); $this->quickCleanup($tablesToTruncate); - CRM_Member_PseudoConstant::membershipType($this->_membershipTypeID, TRUE); + CRM_Member_PseudoConstant::membershipType(NULL, TRUE); CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'name', TRUE); } @@ -462,17 +467,18 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $contribution = new CRM_Contribute_BAO_Contribution(); $contribution->id = $this->_contributionId; $contribution->find(TRUE); + $contributionPageID = NULL; if (!empty($contributionPage)) { $dao = new CRM_Core_DAO(); $contribution_page = $dao->createTestObject('CRM_Contribute_DAO_ContributionPage'); - $contribution->contribution_page_id = $contribution_page->id; - $contribution->save; + $contribution->contribution_page_id = $contributionPageID = $contribution_page->id; + $contribution->save(); } $this->objects['contribution'] = $contribution; $this->input = array( 'component' => 'contribute', - 'contribution_page_id' => $contribution_page->id, + 'contribution_page_id' => $contributionPageID, 'total_amount' => 110.00, 'invoiceID' => "c8acb91e080ad7777a2adc119c192885", 'contactID' => $this->_contactId, -- 2.25.1