Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/197974

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, 26 insertions(+), 9 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/74/197974/1

diff --git a/tests/Adapter/PayPal/PayPalTest.php 
b/tests/Adapter/PayPal/PayPalTest.php
index dcc370f..65ed9c4 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'],
@@ -150,7 +160,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();
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: newchange
Gerrit-Change-Id: Ia6630a90156d7f982201f6539de1bd5d0a9e9ee7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to