jenkins-bot has submitted this change and it was merged.

Change subject: Zoom out PayPal integration tests
......................................................................


Zoom out PayPal integration tests

Use the doPayment API rather than specific APIs, to test one more level of
context.

Change-Id: Ia6630a90156d7f982201f6539de1bd5d0a9e9ee7
---
M tests/Adapter/PayPal/PayPalTest.php
M tests/includes/test_gateway/TestingPaypalAdapter.php
2 files changed, 32 insertions(+), 15 deletions(-)

Approvals:
  Ejegg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/Adapter/PayPal/PayPalTest.php 
b/tests/Adapter/PayPal/PayPalTest.php
index ed40434..9a95484 100644
--- a/tests/Adapter/PayPal/PayPalTest.php
+++ b/tests/Adapter/PayPal/PayPalTest.php
@@ -33,6 +33,12 @@
                $this->testAdapterClass = 'TestingPaypalAdapter';
        }
 
+       public function tearDown() {
+               TestingPaypalAdapter::$fakeGlobals = array();
+
+               parent::tearDown();
+       }
+
        /**
         * Integration test to verify that the Donate transaction works as 
expected when all necessary data is present.
         */
@@ -40,8 +46,8 @@
                $init = $this->getDonorTestData();
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $ret = $gateway->do_transaction( 'Donate' );
-               parse_str( parse_url( $ret['redirect'], PHP_URL_QUERY ), $res );
+               $ret = $gateway->doPayment();
+               parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), 
$res );
 
                $expected = array (
                        'amount' => $init['amount'],
@@ -66,13 +72,12 @@
         * Integration test to verify that the DonateRecurring transaction 
works as expected when all necessary data is present.
         */
        function testDoTransactionDonateRecurring() {
-               global $wgPaypalGatewayRecurringLength;
-
                $init = $this->getDonorTestData();
+               $init['recurring'] = '1';
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $ret = $gateway->do_transaction( 'DonateRecurring' );
-               parse_str( parse_url( $ret['redirect'], PHP_URL_QUERY ), $res );
+               $ret = $gateway->doPayment();
+               parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), 
$res );
 
                $expected = array (
                        'a3' => $init['amount'], //obviously.
@@ -101,10 +106,15 @@
         */
        function testDoTransactionDonateXclick() {
                $init = $this->getDonorTestData();
+
+               TestingPaypalAdapter::$fakeGlobals = array(
+                       'XclickCountries' => array( $init['country'] ),
+               );
+
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $ret = $gateway->do_transaction( 'DonateXclick' );
-               parse_str( parse_url( $ret['redirect'], PHP_URL_QUERY ), $res );
+               $ret = $gateway->doPayment();
+               parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), 
$res );
 
                $expected = array (
                        'amount' => $init['amount'],
@@ -151,7 +161,6 @@
         */
        function testShowFormOnError() {
                $init = $this->getDonorTestData();
-               $init['OTT'] = 'SALT123456789';
                $init['amount'] = '-100.00';
                $_SESSION['Donor'] = $init;
                $errorMessage = 
wfMessage('donate_interface-error-msg-field-correction', 
wfMessage('donate_interface-error-msg-amount')->text())->text();
@@ -175,8 +184,8 @@
                $this->setLanguage( $language );
                $gateway = $this->getFreshGatewayObject( $init );
                $donateText = wfMessage( 
'donate_interface-donation-description' )->inLanguage( $language )->text();
-               $ret = $gateway->do_transaction( 'Donate' );
-               parse_str( parse_url( $ret['redirect'], PHP_URL_QUERY ), $res );
+               $ret = $gateway->doPayment();
+               parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), 
$res );
 
                $expected = array (
                        'amount' => $init['amount'],
@@ -209,8 +218,8 @@
                $this->setLanguage( $language );
                $gateway = $this->getFreshGatewayObject( $init );
                $donateText = wfMessage( 
'donate_interface-donation-description' )->inLanguage( $language )->text();
-               $ret = $gateway->do_transaction( 'Donate' );
-               parse_str( parse_url( $ret['redirect'], PHP_URL_QUERY ), $res );
+               $ret = $gateway->doPayment();
+               parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), 
$res );
 
                $expected = array (
                        'amount' => $init['amount'],
@@ -239,8 +248,8 @@
                $this->setLanguage( 'it' );
                $gateway = $this->getFreshGatewayObject( $init );
                $donateText = wfMessage( 
'donate_interface-donation-description' )->inLanguage( 'it' )->text();
-               $ret = $gateway->do_transaction( 'Donate' );
-               parse_str( parse_url( $ret['redirect'], PHP_URL_QUERY ), $res );
+               $ret = $gateway->doPayment();
+               parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), 
$res );
 
                $expected = array (
                        'amount' => $init['amount'],
diff --git a/tests/includes/test_gateway/TestingPaypalAdapter.php 
b/tests/includes/test_gateway/TestingPaypalAdapter.php
index b799500..29e40dd 100644
--- a/tests/includes/test_gateway/TestingPaypalAdapter.php
+++ b/tests/includes/test_gateway/TestingPaypalAdapter.php
@@ -5,6 +5,8 @@
  * @TODO: Extend/damage things here. I'm sure we'll need it eventually...
  */
 class TestingPaypalAdapter extends PaypalAdapter {
+       public static $fakeGlobals = array();
+
        /**
         * Set the error code you want the dummy response to return
         */
@@ -58,4 +60,10 @@
                );
        }
 
+       public static function getGlobal( $name ) {
+               if ( array_key_exists( $name, 
TestingPaypalAdapter::$fakeGlobals ) ) {
+                       return TestingPaypalAdapter::$fakeGlobals[$name];
+               }
+               return parent::getGlobal( $name );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/197974
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia6630a90156d7f982201f6539de1bd5d0a9e9ee7
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: Katie Horn <kh...@wikimedia.org>
Gerrit-Reviewer: Ssmith <ssm...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to