Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373671 )

Change subject: Set dummy response codes statically
......................................................................

Set dummy response codes statically

Until we can use proper mock curl wrappers, this will let us set
dummy response codes when the test doesn't have access to an instance
of the adapter.

Change-Id: I9085f9e15eff34673f315ac4e55f30edd580c97c
---
M tests/phpunit/Adapter/AstroPay/AstroPayTest.php
M tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
M tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php
M tests/phpunit/Adapter/GlobalCollect/GlobalCollectTest.php
M tests/phpunit/Adapter/GlobalCollect/RecurringTest.php
M tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php
M tests/phpunit/Adapter/Ingenico/IngenicoOrphanRectifierTest.php
M tests/phpunit/Adapter/Ingenico/IngenicoTest.php
M tests/phpunit/Adapter/Ingenico/RecurringTest.php
M tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
M tests/phpunit/DonationInterfaceTestCase.php
M tests/phpunit/LoggingTest.php
M tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php
M tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php
M tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php
M tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php
M tests/phpunit/includes/test_gateway/TestingPaypalExpressAdapter.php
M tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php
18 files changed, 110 insertions(+), 173 deletions(-)


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

diff --git a/tests/phpunit/Adapter/AstroPay/AstroPayTest.php 
b/tests/phpunit/Adapter/AstroPay/AstroPayTest.php
index c30a7f6..703b9da 100644
--- a/tests/phpunit/Adapter/AstroPay/AstroPayTest.php
+++ b/tests/phpunit/Adapter/AstroPay/AstroPayTest.php
@@ -132,7 +132,7 @@
                $init = $this->getDonorTestData( 'BR' );
                $this->setLanguage( $init['language'] );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'notJson' );
+               self::setDummyGatewayResponseCode( 'notJson' );
 
                $gateway->do_transaction( 'NewInvoice' );
 
@@ -148,7 +148,7 @@
                $init = $this->getDonorTestData( 'BR' );
                $this->setLanguage( $init['language'] );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '1' );
+               self::setDummyGatewayResponseCode( '1' );
 
                $gateway->do_transaction( 'NewInvoice' );
 
@@ -203,7 +203,7 @@
                $init = $this->getDonorTestData( 'BR' );
                $this->setLanguage( $init['language'] );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '1' );
+               self::setDummyGatewayResponseCode( '1' );
 
                $result = $gateway->doPayment();
 
@@ -227,7 +227,7 @@
                $this->setLanguage( $init['language'] );
                $init['payment_method'] = 'cc';
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'limit_exceeded' );
+               self::setDummyGatewayResponseCode( 'limit_exceeded' );
 
                $result = $gateway->doPayment();
                $this->assertTrue( $result->getRefresh(), 'PaymentResult should 
be a refresh' );
@@ -245,7 +245,7 @@
                $this->setLanguage( $init['language'] );
                $init['payment_method'] = 'cc';
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'fiscal_number' );
+               self::setDummyGatewayResponseCode( 'fiscal_number' );
 
                $result = $gateway->doPayment();
                $this->assertTrue( $result->getRefresh(), 'PaymentResult should 
be a refresh' );
@@ -263,7 +263,7 @@
                $this->setLanguage( $init['language'] );
                $init['payment_method'] = 'cc';
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'user_unauthorized' );
+               self::setDummyGatewayResponseCode( 'user_unauthorized' );
 
                $result = $gateway->doPayment();
                $this->assertTrue( $result->isFailed() );
@@ -277,7 +277,7 @@
                $this->setLanguage( $init['language'] );
                $init['payment_method'] = 'cc';
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'could_not_register' );
+               self::setDummyGatewayResponseCode( 'could_not_register' );
 
                $result = $gateway->doPayment();
                $this->assertTrue( $result->getRefresh(), 'PaymentResult should 
be a refresh' );
@@ -295,7 +295,7 @@
                $this->setLanguage( $init['language'] );
                $init['payment_method'] = 'cc';
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'could_not_make_deposit' 
);
+               self::setDummyGatewayResponseCode( 'could_not_make_deposit' );
 
                $result = $gateway->doPayment();
                $this->assertTrue( $result->getRefresh(), 'PaymentResult should 
be a refresh' );
@@ -346,7 +346,7 @@
                $this->setUpRequest( $init, $session );
                $gateway = new TestingAstroPayAdapter();
 
-               $gateway->setDummyGatewayResponseCode( 'badsig' );
+               self::setDummyGatewayResponseCode( 'badsig' );
                $gateway->do_transaction( 'PaymentStatus' );
 
                $results = $gateway->getTransactionData();
@@ -515,11 +515,12 @@
                $init = $this->getDonorTestData( 'BR' );
                $firstRequest = $this->setUpRequest( $init );
                $firstAttempt = new TestingAstroPayAdapter();
-               $firstAttempt->setDummyGatewayResponseCode( '1' );
+               self::setDummyGatewayResponseCode( '1' );
  
                $firstAttempt->doPayment();
 
                $this->setUpRequest( $init, $firstRequest->getSessionArray() );
+               self::setDummyGatewayResponseCode( null );
                $secondAttempt = new TestingAstroPayAdapter();
                $secondAttempt->doPayment();
 
@@ -538,7 +539,7 @@
        function testNewInvoiceOrderIdRetry() {
                $init = $this->getDonorTestData( 'BR' );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'collision' );
+               self::setDummyGatewayResponseCode( 'collision' );
  
                $gateway->doPayment();
 
diff --git 
a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php 
b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
index 43816e1..f9ee02c 100644
--- a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
+++ b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
@@ -142,7 +142,7 @@
                $init['contribution_tracking_id'] = mt_rand();
                $gateway->loadDataAndReInit( $init );
 
-               $gateway->setDummyGatewayResponseCode( $code );
+               self::setDummyGatewayResponseCode( $code );
                $result = $gateway->do_transaction( 'Confirm_CreditCard' );
                $this->assertEquals( 1, count( $gateway->curled ), "Gateway 
kept trying even with response code $code!  Mastercard could fine us a thousand 
bucks for that!" );
                $this->assertEquals( false, $result->getCommunicationStatus(), 
"Error code $code should mean status of do_transaction is false" );
@@ -178,7 +178,7 @@
                $init['payment_method'] = 'cc';
 
                $gateway->loadDataAndReInit( $init );
-               $gateway->setDummyGatewayResponseCode( '600_badCvv' );
+               self::setDummyGatewayResponseCode( '600_badCvv' );
 
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $action = $gateway->getValidationAction();
diff --git 
a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php 
b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php
index 0874bc2..f9ef14d 100644
--- a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php
+++ b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php
@@ -71,7 +71,7 @@
 
                $rectifier = new GlobalCollectOrphanRectifier();
                $this->gateway = $rectifier->getAdapter();
-               $this->gateway->setDummyGatewayResponseCode( 
self::STATUS_PENDING );
+               self::setDummyGatewayResponseCode( self::STATUS_PENDING );
                $rectifier->processOrphans();
 
                $fetched = $this->pendingDb->fetchMessageByGatewayOrderId(
@@ -92,7 +92,7 @@
 
                $rectifier = new GlobalCollectOrphanRectifier();
                $this->gateway = $rectifier->getAdapter();
-               $this->gateway->setDummyGatewayResponseCode( 
self::STATUS_PENDING_POKE );
+               self::setDummyGatewayResponseCode( self::STATUS_PENDING_POKE );
                $rectifier->processOrphans();
 
                $fetched = $this->pendingDb->fetchMessageByGatewayOrderId(
@@ -117,7 +117,7 @@
 
                $rectifier = new GlobalCollectOrphanRectifier();
                $this->gateway = $rectifier->getAdapter();
-               $this->gateway->setDummyGatewayResponseCode( 
self::STATUS_COMPLETE );
+               self::setDummyGatewayResponseCode( self::STATUS_COMPLETE );
                $rectifier->processOrphans();
 
                $fetched = $this->pendingDb->fetchMessageByGatewayOrderId(
diff --git a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectTest.php 
b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectTest.php
index a5551ad..7d5e592 100644
--- a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectTest.php
+++ b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectTest.php
@@ -188,7 +188,7 @@
                $this->setUpRequest( array( 'CVVRESULT' => 'M' ) );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '25' );
+               self::setDummyGatewayResponseCode( '25' );
 
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $action = $gateway->getValidationAction();
@@ -216,7 +216,7 @@
                $init['payment_method'] = 'cc';
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( '600_badCvv' );
+               self::setDummyGatewayResponseCode( '600_badCvv' );
 
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $action = $gateway->getValidationAction();
@@ -415,13 +415,13 @@
 
                //this should not throw any payments errors: Just an invalid 
card.
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '430285' );
+               self::setDummyGatewayResponseCode( '430285' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
                $this->verifyNoLogErrors();
 
                //Now test one we want to throw a payments error
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '21000050' );
+               self::setDummyGatewayResponseCode( '21000050' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
                $loglines = self::getLogMatches( LogLevel::ERROR, 
'/Investigation required!/' );
                $this->assertNotEmpty( $loglines, 'GC Error 21000050 is not 
generating the expected payments log error' );
@@ -431,7 +431,7 @@
 
                //Most irritating version of 20001000 - They failed to enter an 
expiration date on GC's form. This should log some specific info, but not an 
error.
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '20001000-expiry' );
+               self::setDummyGatewayResponseCode( '20001000-expiry' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
                $this->verifyNoLogErrors();
                $loglines = self::getLogMatches( LogLevel::INFO, 
'/processResponse:.*EXPIRYDATE/' );
@@ -455,7 +455,7 @@
 
                //Toxic card should not retry, even if there's an order id 
collision
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( $code );
+               self::setDummyGatewayResponseCode( $code );
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $this->assertEquals( 1, count( $gateway->curled ), "Gateway 
kept trying even with response code $code!  Mastercard could fine us a thousand 
bucks for that!" );
        }
@@ -494,7 +494,7 @@
                ) );
 
                $gateway = new TestingGlobalCollectAdapter();
-               $gateway->setDummyGatewayResponseCode( 'Exception' );
+               self::setDummyGatewayResponseCode( 'Exception' );
                try {
                        $gateway->do_transaction( 'INSERT_ORDERWITHPAYMENT' );
                }
@@ -503,6 +503,7 @@
                }
                $first = $gateway->curled[0];
                //simulate another request coming in before we get anything 
back from GC
+               self::setDummyGatewayResponseCode( null );
                $anotherGateway = new TestingGlobalCollectAdapter();
                $anotherGateway->do_transaction( 'INSERT_ORDERWITHPAYMENT' );
                $second = $anotherGateway->curled[0];
@@ -525,7 +526,7 @@
                ) );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( $code );
+               self::setDummyGatewayResponseCode( $code );
                $exposed = TestingAccessWrapper::newFromObject( $gateway );
                $start_id = $exposed->getData_Staged( 'order_id' );
                $gateway->do_transaction( 'Confirm_CreditCard' );
@@ -566,7 +567,7 @@
 
                $gateway = $this->getFreshGatewayObject( $init );
                $orig_id = $gateway->getData_Unstaged_Escaped( 'order_id' );
-               $gateway->setDummyGatewayResponseCode( function ( $gateway ) 
use ( $orig_id ) {
+               self::setDummyGatewayResponseCode( function ( $gateway ) use ( 
$orig_id ) {
                        if ( $gateway->getData_Unstaged_Escaped( 'order_id' ) 
=== $orig_id ) {
                                return 'duplicate';
                        } else {
@@ -593,7 +594,7 @@
                $init['ffname'] = 'cc-vmad';
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '11000400' );
+               self::setDummyGatewayResponseCode( '11000400' );
                $gateway->do_transaction( 'SET_PAYMENT' );
                $loglines = self::getLogMatches( LogLevel::INFO, '/Repeating 
transaction for timeout/' );
                $this->assertNotEmpty( $loglines, "Log does not say we retried 
for timeout." );
@@ -627,7 +628,7 @@
                $session['Donor'] = $init;
                $this->setUpRequest( $init, $session );
                $gateway = $this->getFreshGatewayObject( array() );
-               $gateway->setDummyGatewayResponseCode( '430285' ); // invalid 
card
+               self::setDummyGatewayResponseCode( '430285' ); // invalid card
                $result = $gateway->processDonorReturn( array(
                        'REF' => $init['order_id'],
                        'CVVRESULT' => 'M',
diff --git a/tests/phpunit/Adapter/GlobalCollect/RecurringTest.php 
b/tests/phpunit/Adapter/GlobalCollect/RecurringTest.php
index 64b7923..e7e7b02 100644
--- a/tests/phpunit/Adapter/GlobalCollect/RecurringTest.php
+++ b/tests/phpunit/Adapter/GlobalCollect/RecurringTest.php
@@ -58,7 +58,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-OK' );
+               self::setDummyGatewayResponseCode( 'recurring-OK' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
@@ -81,7 +81,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-declined' );
+               self::setDummyGatewayResponseCode( 'recurring-declined' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
@@ -107,7 +107,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-timeout' );
+               self::setDummyGatewayResponseCode( 'recurring-timeout' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
@@ -132,7 +132,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-resume' );
+               self::setDummyGatewayResponseCode( 'recurring-resume' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
diff --git a/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php 
b/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php
index 582925b..798eb94 100644
--- a/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php
+++ b/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php
@@ -140,7 +140,7 @@
                $init['contribution_tracking_id'] = mt_rand();
                $gateway->loadDataAndReInit( $init );
 
-               $gateway->setDummyGatewayResponseCode( $code );
+               self::setDummyGatewayResponseCode( $code );
                $result = $gateway->do_transaction( 'Confirm_CreditCard' );
                $this->assertEquals( 1, count( $gateway->curled ), "Gateway 
kept trying even with response code $code!  Mastercard could fine us a thousand 
bucks for that!" );
                $this->assertEquals( false, $result->getCommunicationStatus(), 
"Error code $code should mean status of do_transaction is false" );
@@ -177,7 +177,7 @@
                $init['payment_method'] = 'cc';
 
                $gateway->loadDataAndReInit( $init );
-               $gateway->setDummyGatewayResponseCode( '600_badCvv' );
+               self::setDummyGatewayResponseCode( '600_badCvv' );
 
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $action = $gateway->getValidationAction();
diff --git a/tests/phpunit/Adapter/Ingenico/IngenicoOrphanRectifierTest.php 
b/tests/phpunit/Adapter/Ingenico/IngenicoOrphanRectifierTest.php
index 4926c49..4514b93 100644
--- a/tests/phpunit/Adapter/Ingenico/IngenicoOrphanRectifierTest.php
+++ b/tests/phpunit/Adapter/Ingenico/IngenicoOrphanRectifierTest.php
@@ -76,7 +76,7 @@
 
                $rectifier = new IngenicoOrphanRectifier();
                $this->gateway = $rectifier->getAdapter();
-               $this->gateway->setDummyGatewayResponseCode( 
self::STATUS_PENDING );
+               self::setDummyGatewayResponseCode( self::STATUS_PENDING );
                $rectifier->processOrphans();
 
                $fetched = $this->pendingDb->fetchMessageByGatewayOrderId(
@@ -97,7 +97,7 @@
 
                $rectifier = new IngenicoOrphanRectifier();
                $this->gateway = $rectifier->getAdapter();
-               $this->gateway->setDummyGatewayResponseCode( 
self::STATUS_PENDING_POKE );
+               self::setDummyGatewayResponseCode( self::STATUS_PENDING_POKE );
                $rectifier->processOrphans();
 
                $fetched = $this->pendingDb->fetchMessageByGatewayOrderId(
@@ -122,7 +122,7 @@
 
                $rectifier = new IngenicoOrphanRectifier();
                $this->gateway = $rectifier->getAdapter();
-               $this->gateway->setDummyGatewayResponseCode( 
self::STATUS_COMPLETE );
+               self::setDummyGatewayResponseCode( self::STATUS_COMPLETE );
                $rectifier->processOrphans();
 
                $fetched = $this->pendingDb->fetchMessageByGatewayOrderId(
diff --git a/tests/phpunit/Adapter/Ingenico/IngenicoTest.php 
b/tests/phpunit/Adapter/Ingenico/IngenicoTest.php
index dcddcae..dea2f81 100644
--- a/tests/phpunit/Adapter/Ingenico/IngenicoTest.php
+++ b/tests/phpunit/Adapter/Ingenico/IngenicoTest.php
@@ -128,7 +128,7 @@
                $this->setUpRequest( array( 'CVVRESULT' => 'M' ) );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '25' );
+               self::setDummyGatewayResponseCode( '25' );
 
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $action = $gateway->getValidationAction();
@@ -157,7 +157,7 @@
                $init['payment_method'] = 'cc';
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( '600_badCvv' );
+               self::setDummyGatewayResponseCode( '600_badCvv' );
 
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $action = $gateway->getValidationAction();
@@ -284,13 +284,13 @@
 
                //this should not throw any payments errors: Just an invalid 
card.
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '430285' );
+               self::setDummyGatewayResponseCode( '430285' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
                $this->verifyNoLogErrors();
 
                //Now test one we want to throw a payments error
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '21000050' );
+               self::setDummyGatewayResponseCode( '21000050' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
                $loglines = $this->getLogMatches( LogLevel::ERROR, 
'/Investigation required!/' );
                $this->assertNotEmpty( $loglines, 'GC Error 21000050 is not 
generating the expected payments log error' );
@@ -300,7 +300,7 @@
 
                //Most irritating version of 20001000 - They failed to enter an 
expiration date on GC's form. This should log some specific info, but not an 
error.
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '20001000-expiry' );
+               self::setDummyGatewayResponseCode( '20001000-expiry' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
                $this->verifyNoLogErrors();
                $loglines = $this->getLogMatches( LogLevel::INFO, 
'/processResponse:.*EXPIRYDATE/' );
@@ -325,7 +325,7 @@
 
                //Toxic card should not retry, even if there's an order id 
collision
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( $code );
+               self::setDummyGatewayResponseCode( $code );
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $this->assertEquals( 1, count( $gateway->curled ), "Gateway 
kept trying even with response code $code!  Mastercard could fine us a thousand 
bucks for that!" );
        }
@@ -408,7 +408,7 @@
                ) );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( $code );
+               self::setDummyGatewayResponseCode( $code );
                $exposed = TestingAccessWrapper::newFromObject( $gateway );
                $start_id = $exposed->getData_Staged( 'order_id' );
                $gateway->do_transaction( 'Confirm_CreditCard' );
@@ -466,7 +466,7 @@
                $session['Donor'] = $init;
                $this->setUpRequest( $init, $session );
                $gateway = $this->getFreshGatewayObject( array() );
-               $gateway->setDummyGatewayResponseCode( '430285' ); // invalid 
card
+               self::setDummyGatewayResponseCode( '430285' ); // invalid card
                $result = $gateway->processDonorReturn( array(
                        'REF' => $init['order_id'],
                        'CVVRESULT' => 'M',
diff --git a/tests/phpunit/Adapter/Ingenico/RecurringTest.php 
b/tests/phpunit/Adapter/Ingenico/RecurringTest.php
index 20e2bf5..7151599 100644
--- a/tests/phpunit/Adapter/Ingenico/RecurringTest.php
+++ b/tests/phpunit/Adapter/Ingenico/RecurringTest.php
@@ -45,7 +45,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-OK' );
+               self::setDummyGatewayResponseCode( 'recurring-OK' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
@@ -68,7 +68,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-declined' );
+               self::setDummyGatewayResponseCode( 'recurring-declined' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
@@ -100,7 +100,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-timeout' );
+               self::setDummyGatewayResponseCode( 'recurring-timeout' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
@@ -125,7 +125,7 @@
                );
                $gateway = $this->getFreshGatewayObject( $init );
 
-               $gateway->setDummyGatewayResponseCode( 'recurring-resume' );
+               self::setDummyGatewayResponseCode( 'recurring-resume' );
 
                $result = $gateway->do_transaction( 'Recurring_Charge' );
 
diff --git a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php 
b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
index ccb3dfc..a1f3e36 100644
--- a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
+++ b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
@@ -45,7 +45,7 @@
                        'language' => 'fr',
                );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'OK' );
+               self::setDummyGatewayResponseCode( 'OK' );
                $result = $gateway->doPayment();
                $gateway->logPending(); // GatewayPage or the API calls this 
for redirects
                $this->assertEquals(
@@ -98,7 +98,7 @@
                        'language' => 'fr',
                );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'OK' );
+               self::setDummyGatewayResponseCode( 'OK' );
                $result = $gateway->doPayment();
                $gateway->logPending(); // GatewayPage or the API calls this 
for redirects
                $this->assertEquals(
@@ -148,7 +148,7 @@
                $this->setUpRequest( $init, array( 'Donor' => $init ) );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'OK' );
+               self::setDummyGatewayResponseCode( 'OK' );
                $gateway->processDonorReturn( array(
                        'token' => 'EC%2d4V987654XA123456V',
                        'PayerID' => 'ASDASD',
@@ -198,7 +198,7 @@
                $init['recurring'] = '1';
                $this->setUpRequest( $init, array( 'Donor' => $init ) );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( 'Recurring-OK' );
+               self::setDummyGatewayResponseCode( 'Recurring-OK' );
                $gateway->processDonorReturn( array(
                        'token' => 'EC%2d4V987654XA123456V',
                        'PayerID' => 'ASDASD'
@@ -217,7 +217,7 @@
                $this->setUpRequest( $init, array( 'Donor' => $init ) );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '10486' );
+               self::setDummyGatewayResponseCode( '10486' );
                $result = $gateway->processDonorReturn( array(
                        'token' => 'EC%2d2D123456D9876543U',
                        'PayerID' => 'ASDASD'
@@ -239,7 +239,7 @@
                $init['recurring'] = '1';
                $this->setUpRequest( $init, array( 'Donor' => $init ) );
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '10486' );
+               self::setDummyGatewayResponseCode( '10486' );
                $result = $gateway->processDonorReturn( array(
                        'token' => 'EC%2d2D123456D9876543U',
                        'PayerID' => 'ASDASD'
diff --git a/tests/phpunit/DonationInterfaceTestCase.php 
b/tests/phpunit/DonationInterfaceTestCase.php
index 7e4c42d..d615824 100644
--- a/tests/phpunit/DonationInterfaceTestCase.php
+++ b/tests/phpunit/DonationInterfaceTestCase.php
@@ -53,6 +53,11 @@
        protected $testAdapterClass = TESTS_ADAPTER_DEFAULT;
        protected $smashPigGlobalConfig;
 
+
+       public static $dummyGatewayResponseCode = null;
+
+       public static $dummyCurlResponseCode = null;
+
        /**
         * @param $name string The name of the test case
         * @param $data array Any parameters read from a dataProvider
@@ -499,6 +504,9 @@
 
                RequestContext::resetMain();
 
+               self::$dummyGatewayResponseCode = null;
+               self::$dummyCurlResponseCode = null;
+
                // Wipe out the $instance of these classes to make sure they're
                // re-created with fresh gateway instances for the next test
                $singleton_classes = array(
@@ -722,4 +730,18 @@
                        unset( $message[$field] );
                }
        }
+
+       /**
+        * Set the error code you want the dummy response to return
+        */
+       public static function setDummyGatewayResponseCode( $code ) {
+               self::$dummyGatewayResponseCode = $code;
+       }
+
+       /**
+        * Set the error code you want the dummy response to return
+        */
+       public static function setDummyCurlResponseCode( $code ) {
+               self::$dummyCurlResponseCode = $code;
+       }
 }
diff --git a/tests/phpunit/LoggingTest.php b/tests/phpunit/LoggingTest.php
index c452c85..debdb64 100644
--- a/tests/phpunit/LoggingTest.php
+++ b/tests/phpunit/LoggingTest.php
@@ -77,7 +77,7 @@
                );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '200' );
+               self::setDummyGatewayResponseCode( '200' );
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $preface_pattern = '/' . preg_quote( 
GatewayAdapter::COMPLETED_PREFACE ) . '/';
                $matches = self::getLogMatches( LogLevel::INFO, 
$preface_pattern );
@@ -130,7 +130,7 @@
                );
 
                $gateway = $this->getFreshGatewayObject( $init );
-               $gateway->setDummyGatewayResponseCode( '200' );
+               self::setDummyGatewayResponseCode( '200' );
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $preface_pattern = '/' . preg_quote( 
GatewayAdapter::COMPLETED_PREFACE ) . '/';
                $matches = self::getLogMatches( LogLevel::INFO, 
$preface_pattern );
diff --git a/tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php 
b/tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php
index bc79ae7..6ea892a 100644
--- a/tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php
+++ b/tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php
@@ -17,26 +17,12 @@
        }
 
        /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyGatewayResponseCode( $code ) {
-               $this->dummyGatewayResponseCode = $code;
-       }
-
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyCurlResponseCode( $code ) {
-               $this->dummyCurlResponseCode = $code;
-       }
-
-       /**
         * Load in some dummy response XML so we can test proper response 
processing
         */
        protected function curl_exec( $ch ) {
                $code = '';
-               if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) {
-                       $code = '_' . $this->dummyGatewayResponseCode;
+               if ( DonationInterfaceTestCase::$dummyGatewayResponseCode ) {
+                       $code = '_' . 
DonationInterfaceTestCase::$dummyGatewayResponseCode;
                }
 
                //could start stashing these in a further-down subdir if 
payment type starts getting in the way,
@@ -57,8 +43,8 @@
         */
        protected function curl_getinfo( $ch, $opt = null ) {
                $code = 200; //response OK
-               if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
-                       $code = ( int ) $this->dummyCurlResponseCode;
+               if ( DonationInterfaceTestCase::$dummyCurlResponseCode ) {
+                       $code = ( int ) 
DonationInterfaceTestCase::$dummyCurlResponseCode;
                }
 
                //put more here if it ever turns out that we care about it.
diff --git a/tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php 
b/tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php
index fcc224c..f3b0f13 100644
--- a/tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php
+++ b/tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php
@@ -10,20 +10,6 @@
 
        public $curled = array();
 
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyGatewayResponseCode( $code ) {
-               $this->dummyGatewayResponseCode = $code;
-       }
-
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyCurlResponseCode( $code ) {
-               $this->dummyCurlResponseCode = $code;
-       }
-
        protected function curl_transaction( $data ) {
                $this->curled[] = $data;
                return parent::curl_transaction( $data );
@@ -35,9 +21,9 @@
         */
        protected function curl_exec( $ch ) {
                $code = '';
-               if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) {
-                       $code = '_' . $this->dummyGatewayResponseCode;
-                       if ( $this->dummyGatewayResponseCode === 'Exception' ) {
+               if ( DonationInterfaceTestCase::$dummyGatewayResponseCode ) {
+                       $code = '_' . 
DonationInterfaceTestCase::$dummyGatewayResponseCode;
+                       if ( 
DonationInterfaceTestCase::$dummyGatewayResponseCode === 'Exception' ) {
                                throw new RuntimeException( 'blah!' );
                        }
                }
@@ -64,8 +50,8 @@
         */
        protected function curl_getinfo( $ch, $opt = null ) {
                $code = 200; //response OK
-               if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
-                       $code = ( int ) $this->dummyCurlResponseCode;
+               if ( DonationInterfaceTestCase::$dummyCurlResponseCode ) {
+                       $code = ( int ) 
DonationInterfaceTestCase::$dummyCurlResponseCode;
                }
 
                //put more here if it ever turns out that we care about it.
diff --git 
a/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php 
b/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php
index a936b6c..b6b34b2 100644
--- a/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php
+++ b/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php
@@ -9,8 +9,6 @@
 
        public $curled = array ( );
 
-       public $dummyGatewayResponseCode;
-
        /**
         * Also set a useful MerchantID.
         */
@@ -45,20 +43,6 @@
                parent::defineOrderIDMeta();
        }
 
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyGatewayResponseCode( $code ) {
-               $this->dummyGatewayResponseCode = $code;
-       }
-
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyCurlResponseCode( $code ) {
-               $this->dummyCurlResponseCode = $code;
-       }
-
        protected function curl_transaction( $data ) {
                $this->curled[] = $data;
                return parent::curl_transaction( $data );
@@ -70,13 +54,13 @@
         */
        protected function curl_exec( $ch ) {
                $code = '';
-               if ( $this->dummyGatewayResponseCode ) {
-                       if ( is_array( $this->dummyGatewayResponseCode ) ) {
-                               $code = array_shift( 
$this->dummyGatewayResponseCode );
-                       } elseif ( is_callable( $this->dummyGatewayResponseCode 
) ) {
-                               $code = call_user_func( 
$this->dummyGatewayResponseCode, $this );
+               if ( DonationInterfaceTestCase::$dummyGatewayResponseCode ) {
+                       if ( is_array( 
DonationInterfaceTestCase::$dummyGatewayResponseCode ) ) {
+                               $code = array_shift( 
DonationInterfaceTestCase::$dummyGatewayResponseCode );
+                       } elseif ( is_callable( 
DonationInterfaceTestCase::$dummyGatewayResponseCode ) ) {
+                               $code = call_user_func( 
DonationInterfaceTestCase::$dummyGatewayResponseCode, $this );
                        } else {
-                               $code = $this->dummyGatewayResponseCode;
+                               $code = 
DonationInterfaceTestCase::$dummyGatewayResponseCode;
                        }
                }
                if ( $code ) {
@@ -104,8 +88,8 @@
         */
        protected function curl_getinfo( $ch, $opt = null ) {
                $code = 200; //response OK
-               if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
-                       $code = ( int ) $this->dummyCurlResponseCode;
+               if ( DonationInterfaceTestCase::$dummyCurlResponseCode ) {
+                       $code = ( int ) 
DonationInterfaceTestCase::$dummyCurlResponseCode;
                }
 
                //put more here if it ever turns out that we care about it.
diff --git 
a/tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php 
b/tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php
index 2b155f2..dee7dfd 100644
--- a/tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php
+++ b/tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php
@@ -43,20 +43,6 @@
                parent::defineOrderIDMeta();
        }
 
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyGatewayResponseCode( $code ) {
-               $this->dummyGatewayResponseCode = $code;
-       }
-
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyCurlResponseCode( $code ) {
-               $this->dummyCurlResponseCode = $code;
-       }
-
        protected function curl_transaction( $data ) {
                $this->curled[] = $data;
                return parent::curl_transaction( $data );
@@ -67,8 +53,8 @@
         */
        protected function curl_exec( $ch ) {
                $code = '';
-               if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) {
-                       $code = '_' . $this->dummyGatewayResponseCode;
+               if ( DonationInterfaceTestCase::$dummyGatewayResponseCode ) {
+                       $code = '_' . 
DonationInterfaceTestCase::$dummyGatewayResponseCode;
                }
 
                //could start stashing these in a further-down subdir if 
payment type starts getting in the way,
@@ -89,8 +75,8 @@
         */
        protected function curl_getinfo( $ch, $opt = null ) {
                $code = 200; //response OK
-               if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
-                       $code = ( int ) $this->dummyCurlResponseCode;
+               if ( DonationInterfaceTestCase::$dummyCurlResponseCode ) {
+                       $code = ( int ) 
DonationInterfaceTestCase::$dummyCurlResponseCode;
                }
 
                //put more here if it ever turns out that we care about it.
diff --git 
a/tests/phpunit/includes/test_gateway/TestingPaypalExpressAdapter.php 
b/tests/phpunit/includes/test_gateway/TestingPaypalExpressAdapter.php
index 18b3f4b..fe5ea3a 100644
--- a/tests/phpunit/includes/test_gateway/TestingPaypalExpressAdapter.php
+++ b/tests/phpunit/includes/test_gateway/TestingPaypalExpressAdapter.php
@@ -4,29 +4,14 @@
  * FIXME so much: DRY
  */
 class TestingPaypalExpressAdapter extends PaypalExpressAdapter {
-       protected $dummyGatewayResponseCode = 'OK';
-
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyGatewayResponseCode( $code ) {
-               $this->dummyGatewayResponseCode = $code;
-       }
-
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyCurlResponseCode( $code ) {
-               $this->dummyCurlResponseCode = $code;
-       }
 
        /**
         * Load in some dummy response XML so we can test proper response 
processing
         */
        protected function curl_exec( $ch ) {
-               $code = '';
-               if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) {
-                       $code = '_' . $this->dummyGatewayResponseCode;
+               $code = '_OK';
+               if ( DonationInterfaceTestCase::$dummyGatewayResponseCode ) {
+                       $code = '_' . 
DonationInterfaceTestCase::$dummyGatewayResponseCode;
                }
 
                //could start stashing these in a further-down subdir if 
payment type starts getting in the way,
@@ -47,8 +32,8 @@
         */
        protected function curl_getinfo( $ch, $opt = null ) {
                $code = 200; //response OK
-               if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
-                       $code = ( int ) $this->dummyCurlResponseCode;
+               if ( DonationInterfaceTestCase::$dummyCurlResponseCode ) {
+                       $code = ( int ) 
DonationInterfaceTestCase::$dummyCurlResponseCode;
                }
 
                //put more here if it ever turns out that we care about it.
diff --git a/tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php 
b/tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php
index 2f654c2..395d49c 100644
--- a/tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php
+++ b/tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php
@@ -7,26 +7,12 @@
        public static $fakeGlobals = array();
 
        /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyGatewayResponseCode( $code ) {
-               $this->dummyGatewayResponseCode = $code;
-       }
-
-       /**
-        * Set the error code you want the dummy response to return
-        */
-       public function setDummyCurlResponseCode( $code ) {
-               $this->dummyCurlResponseCode = $code;
-       }
-
-       /**
         * Load in some dummy response XML so we can test proper response 
processing
         */
        protected function curl_exec( $ch ) {
                $code = '';
-               if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) {
-                       $code = '_' . $this->dummyGatewayResponseCode;
+               if ( DonationInterfaceTestCase::$dummyGatewayResponseCode ) {
+                       $code = '_' . 
DonationInterfaceTestCase::$dummyGatewayResponseCode;
                }
 
                //could start stashing these in a further-down subdir if 
payment type starts getting in the way,
@@ -47,8 +33,8 @@
         */
        protected function curl_getinfo( $ch, $opt = null ) {
                $code = 200; //response OK
-               if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
-                       $code = ( int ) $this->dummyCurlResponseCode;
+               if ( DonationInterfaceTestCase::$dummyCurlResponseCode ) {
+                       $code = ( int ) 
DonationInterfaceTestCase::$dummyCurlResponseCode;
                }
 
                //put more here if it ever turns out that we care about it.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9085f9e15eff34673f315ac4e55f30edd580c97c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>

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

Reply via email to