From 3aaa68fb080c30fbf7b8c591471a5de8dc59d96c Mon Sep 17 00:00:00 2001 From: eileenmcnaughton Date: Thu, 3 Dec 2015 09:37:06 +0000 Subject: [PATCH] some somment fixes --- CRM/Core/Payment/BaseIPN.php | 18 +++++------ .../phpunit/CRM/Core/Payment/BaseIPNTest.php | 31 ++++++++++++++++--- .../CRM/Core/Payment/PayPalProIPNTest.php | 23 ++++++++++++-- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index 7aec4e12a5..c44d43e8b8 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -141,14 +141,14 @@ class CRM_Core_Payment_BaseIPN { * * @input array information from Payment processor * - * @param $input + * @param array $input * @param array $ids * @param array $objects * @param bool $required * @param int $paymentProcessorID * @param array $error_handling * - * @return bool + * @return bool|array */ public function loadObjects(&$input, &$ids, &$objects, $required, $paymentProcessorID, $error_handling = NULL) { if (empty($error_handling)) { @@ -221,7 +221,7 @@ class CRM_Core_Payment_BaseIPN { } $participant = &$objects['participant']; - //CRM-15546 + // CRM-15546 $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array( 'labelColumn' => 'name', 'flip' => 1, @@ -297,8 +297,8 @@ class CRM_Core_Payment_BaseIPN { /** * Process cancelled payment outcome. * - * @param $objects - * @param $transaction + * @param array $objects + * @param CRM_Core_Transaction $transaction * @param array $input * * @return bool @@ -375,8 +375,8 @@ class CRM_Core_Payment_BaseIPN { /** * Rollback unhandled outcomes. * - * @param $objects - * @param $transaction + * @param array $objects + * @param CRM_Core_Transaction $transaction * * @return bool */ @@ -437,7 +437,7 @@ class CRM_Core_Payment_BaseIPN { * @param array $input * @param array $ids * @param array $objects - * @param $transaction + * @param CRM_Core_Transaction $transaction * @param bool $recur */ public function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = FALSE) { @@ -478,7 +478,7 @@ class CRM_Core_Payment_BaseIPN { * Incoming data from Payment processor. * @param array $ids * Related object IDs. - * @param $objects + * @param array $objects * @param array $values * Values related to objects that have already been loaded. * @param bool $recur diff --git a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php index 98d594bc39..6dcfcd12dc 100644 --- a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php @@ -43,6 +43,19 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { protected $_processorId; protected $_contributionRecurParams; protected $_paymentProcessor; + + /** + * Parameters to create a membership. + * + * @var array + */ + protected $_membershipParams = array(); + + /** + * IPN instance. + * + * @var CRM_Core_Payment_BaseIPN + */ protected $IPN; protected $_recurId; protected $_membershipId; @@ -61,6 +74,9 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { protected $_membershipStatusID; public $DBResetRequired = FALSE; + /** + * Setup function. + */ public function setUp() { parent::setUp(); $this->_processorId = $this->paymentProcessorAuthorizeNetCreate(array('is_test' => 0)); @@ -90,6 +106,9 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->objects['contribution'] = $contribution; } + /** + * Tear down after class. + */ public function tearDown() { $this->quickCleanUpFinancialEntities(); CRM_Member_PseudoConstant::membershipType(NULL, TRUE); @@ -120,7 +139,11 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId); $this->assertEquals('Anthony', $this->objects['contact']->first_name); - $this->ids['contact'] = $this->_contactId = $this->individualCreate(array('first_name' => 'Donald', 'last_name' => 'Duck', 'email' => 'the-don@duckville.com')); + $this->ids['contact'] = $this->_contactId = $this->individualCreate(array( + 'first_name' => 'Donald', + 'last_name' => 'Duck', + 'email' => 'the-don@duckville.com, + ')); $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams, array('invoice_id' => 'abc'))); $this->_contributionId = $contribution['id']; $this->_setUpMembershipObjects(); @@ -340,7 +363,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { } /** - * Test that an error is returned if required set & no contribution page + * Test that an error is returned if required set & no contribution page. */ public function testRequiredWithoutProcessorID() { $this->_setUpPledgeObjects(); @@ -596,8 +619,8 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { 'event_id' => $this->_eventId, 'contact_id' => $this->_contactId, )); - //we'll create membership payment here because to make setup more re-usable - $participantPayment = $this->callAPISuccess('participant_payment', 'create', array( + + $this->callAPISuccess('participant_payment', 'create', array( 'contribution_id' => $this->_contributionId, 'participant_id' => $this->_participantId, )); diff --git a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php index a118204944..f65b86c00d 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php @@ -38,7 +38,16 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { protected $_contributionRecurID; protected $_contributionPageID; protected $_paymentProcessorID; + /** + * IDs of entities created to support the tests. + * + * @var array + */ + protected $ids = array(); + /** + * Set up function. + */ public function setUp() { parent::setUp(); $this->_paymentProcessorID = $this->paymentProcessorCreate(array('is_test' => 0)); @@ -53,6 +62,9 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $this->_contributionPageID = $contributionPage['id']; } + /** + * Tear down function. + */ public function tearDown() { $this->quickCleanUpFinancialEntities(); } @@ -85,7 +97,7 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { } /** - * Test IPN response updates contribution_recur & contribution for first & second contribution + * Test IPN response updates contribution_recur & contribution for first & second contribution. */ public function testIPNPaymentMembershipRecurSuccess() { $this->setupMembershipRecurringPaymentProcessorTransaction(); @@ -122,7 +134,8 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { } /** - * CRM-13743 test IPN edge case where the first transaction fails and the second succeeds + * CRM-13743 test IPN edge case where the first transaction fails and the second succeeds. + * * We are checking that the created contribution has the same date as IPN says it should * Note that only one contribution will be created (no evidence of the failed contribution is left) * It seems likely that may change in future & this test will start failing (I point this out in the hope it @@ -152,7 +165,8 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { } /** - * Check a payment express IPN call does not throw any errors + * Check a payment express IPN call does not throw any errors. + * * At this stage nothing it supposed to happen so it's a pretty blunt test * but at least it should be e-notice free * The browser interaction will update Paypal express payments @@ -294,6 +308,7 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { } /** + * Get IPN style details for an incoming recurring transaction. */ public function getPaypalProRecurTransaction() { return array( @@ -343,6 +358,8 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { } /** + * Get IPN-style details for a second incoming transaction. + * * @return array */ public function getPaypalProRecurSubsequentTransaction() { -- 2.25.1