Katie Horn has submitted this change and it was merged.
Change subject: Merge branch 'master' into deploy-payments_1.22
......................................................................
Merge branch 'master' into deploy-payments_1.22
Conflicts:
tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTestCase.php
tests/Adapter/GlobalCollect/GlobalCollectTestCase.php
tests/DonationInterfaceTestCase.php
tests/includes/test_gateway/test.adapter.php
Change-Id: Ic85670419e0bab6d4eb1d6c148fbf83eb00d24a5
---
D tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTestCase.php
D tests/Adapter/GlobalCollect/GlobalCollectTestCase.php
D tests/DonationInterfaceTestCase.php
D tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430260.testresponse
D tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430306.testresponse
D tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430330.testresponse
D tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430354.testresponse
D tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430357.testresponse
D tests/includes/test_gateway/test.adapter.php
9 files changed, 0 insertions(+), 2,176 deletions(-)
Approvals:
Katie Horn: Looks good to me, approved
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTestCase.php
b/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTestCase.php
deleted file mode 100644
index a2d86ff..0000000
--- a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTestCase.php
+++ /dev/null
@@ -1,184 +0,0 @@
-<<<<<<< HEAD (64ab77 Merge branch 'master' into deploy-payments_1.22)
-=======
-<?php
-
-/**
- * Wikimedia Foundation
- *
- * LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-/**
- *
- * @group Fundraising
- * @group DonationInterface
- * @group GlobalCollect
- * @group OrphanSlayer
- */
-class DonationInterface_Adapter_GlobalCollect_Orphans_GlobalCollectTestCase
extends DonationInterfaceTestCase {
-
- /**
- * @param $name string The name of the test case
- * @param $data array Any parameters read from a dataProvider
- * @param $dataName string|int The name or index of the data set
- */
- function __construct( $name = null, array $data = array(), $dataName =
'' ) {
- parent::__construct( $name, $data, $dataName );
- $this->testAdapterClass = 'TestingGlobalCollectOrphanAdapter';
- $this->dummy_utm_data = array (
- 'utm_source' => 'dummy_source',
- 'utm_campaign' => 'dummy_campaign',
- 'utm_medium' => 'dummy_medium',
- 'date' => time(),
- );
- }
-
- public function testConstructor() {
-
- $options = $this->getDonorTestData();
- $class = $this->testAdapterClass;
-
- $gateway = $this->getFreshGatewayObject();
-
- $this->assertInstanceOf( $class, $gateway );
-
- $this->verifyNoLogErrors( $gateway );
- }
-
-
- public function testBatchOrderID_generate() {
-
- //no data on construct, generate Order IDs
- $gateway = $this->getFreshGatewayObject( null, array (
'order_id_meta' => array ( 'generate' => TRUE ) ) );
- $this->assertTrue( $gateway->getOrderIDMeta( 'generate' ), 'The
order_id meta generate setting override is not working properly. Order_id
generation may be broken.' );
- $this->assertNotNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), 'Failed asserting that an absent order id is not left as null,
when generating our own' );
-
- $data = array_merge( $this->getDonorTestData(),
$this->dummy_utm_data );
- $data['order_id'] = '55555';
-
- //now, add data and check that we didn't kill the oid. Still
generating.
- $gateway->loadDataAndReInit( $data, $useDB = false );
- $this->assertEquals( $gateway->getData_Unstaged_Escaped(
'order_id' ), '55555', 'loadDataAndReInit failed to stick OrderID' );
-
- $data['order_id'] = '444444';
- $gateway->loadDataAndReInit( $data, $useDB = false );
- $this->assertEquals( $gateway->getData_Unstaged_Escaped(
'order_id' ), '444444', 'loadDataAndReInit failed to stick OrderID' );
-
- $this->verifyNoLogErrors( $gateway );
- }
-
- public function testBatchOrderID_no_generate() {
-
- //no data on construct, do not generate Order IDs
- $gateway = $this->getFreshGatewayObject( null, array (
'order_id_meta' => array ( 'generate' => FALSE ) ) );
- $this->assertFalse( $gateway->getOrderIDMeta( 'generate' ),
'The order_id meta generate setting override is not working properly. Deferred
order_id generation may be broken.' );
- $this->assertNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), 'Failed asserting that an absent order id is left as null, when
not generating our own' );
-
- $data = array_merge( $this->getDonorTestData(),
$this->dummy_utm_data );
- $data['order_id'] = '66666';
-
- //now, add data and check that we didn't kill the oid. Still
not generating
- $gateway->loadDataAndReInit( $data, $useDB = false );
- $this->assertEquals( $gateway->getData_Unstaged_Escaped(
'order_id' ), '66666', 'loadDataAndReInit failed to stick OrderID' );
-
- $data['order_id'] = '777777';
- $gateway->loadDataAndReInit( $data, $useDB = false );
- $this->assertEquals( $gateway->getData_Unstaged_Escaped(
'order_id' ), '777777', 'loadDataAndReInit failed to stick OrderID on second
batch item' );
-
- $this->verifyNoLogErrors( $gateway );
- }
-
- public function testGCFormLoad() {
- $init = $this->getDonorTestData( 'US' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'cc-vmad';
-
- $assertNodes = array (
- 'cc-mc' => array (
- 'nodename' => 'input'
- ),
- 'selected-amount' => array (
- 'nodename' => 'span',
- 'innerhtml' => '$1.55',
- ),
- 'state' => array (
- 'nodename' => 'select',
- 'selected' => 'CA',
- ),
- );
-
- $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init,
$assertNodes, true );
- }
-
- function testGCFormLoad_FR() {
- $init = $this->getDonorTestData( 'FR' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'cc-vmaj';
-
- $assertNodes = array (
- 'selected-amount' => array (
- 'nodename' => 'span',
- 'innerhtml' => '€1.55',
- ),
- 'fname' => array (
- 'nodename' => 'input',
- 'value' => 'Prénom',
- ),
- 'lname' => array (
- 'nodename' => 'input',
- 'value' => 'Nom',
- ),
- 'informationsharing' => array (
- 'nodename' => 'p',
- 'innerhtml' => "En faisant ce don, vous
acceptez notre politique de confidentialité en matière de donation ainsi que de
partager vos données personnelles avec la <a
href=\"https://wikimediafoundation.org/wiki/Special:LandingCheck?basic=true&landing_page=Tax_Deductibility&country=FR&language=fr&uselang=fr\">Fondation
Wikimédia</a> et ses prestataires de services situés aux Etats-Unis et
ailleurs.",
- ),
- 'country' => array (
- 'nodename' => 'select',
- 'selected' => 'FR',
- ),
- );
-
- $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init,
$assertNodes, true );
- }
-
- /**
- * Tests to make sure that certain error codes returned from GC will
- * trigger order cancellation, even if retryable errors also exist.
- * @dataProvider mcNoRetryCodeProvider
- */
- public function testNoMastercardFinesForRepeatOnBadCodes( $code ) {
- $gateway = $this->getFreshGatewayObject( null, array (
'order_id_meta' => array ( 'generate' => FALSE ) ) );
-
- //Toxic card should not retry, even if there's an order id
collision
- $init = array_merge( $this->getDonorTestData(),
$this->dummy_utm_data );
- $init['ffname'] = 'cc-vmad';
- $init['order_id'] = '55555';
- $init['email'] = '[email protected]';
- $gateway->loadDataAndReInit( $init, $useDB = false );
-
- $gateway->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['status'], "Error code
$code should mean status of do_transaction is false" );
- $this->assertTrue( array_key_exists( 'errors', $result ),
'Orphan adapter needs to see the errors to consider it rectified' );
- $this->assertTrue( array_key_exists('1000001',
$result['errors'] ), 'Orphan adapter needs error 1000001 to consider it
rectified' );
- $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO,
"/Got error code $code, not retrying to avoid MasterCard fines./" );
- $this->assertType( 'string', $logline, "GC Error $code is not
generating the expected payments log error" );
- }
-}
->>>>>>> BRANCH (5e90d5 Add IP spanking for shady cards to Worldpay)
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectTestCase.php
b/tests/Adapter/GlobalCollect/GlobalCollectTestCase.php
deleted file mode 100644
index 83bef78..0000000
--- a/tests/Adapter/GlobalCollect/GlobalCollectTestCase.php
+++ /dev/null
@@ -1,355 +0,0 @@
-<<<<<<< HEAD (64ab77 Merge branch 'master' into deploy-payments_1.22)
-=======
-<?php
-/**
- * Wikimedia Foundation
- *
- * LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-/**
- *
- * @group Fundraising
- * @group DonationInterface
- * @group GlobalCollect
- */
-class DonationInterface_Adapter_GlobalCollect_GlobalCollectTestCase extends
DonationInterfaceTestCase {
-
- /**
- * @param $name string The name of the test case
- * @param $data array Any parameters read from a dataProvider
- * @param $dataName string|int The name or index of the data set
- */
- function __construct( $name = null, array $data = array(), $dataName =
'' ) {
- parent::__construct( $name, $data, $dataName );
- $this->testAdapterClass = 'TestingGlobalCollectAdapter';
- }
-
- function tearDown() {
- TestingGlobalCollectAdapter::clearGlobalsCache();
- parent::tearDown();
- }
-
- /**
- * testnormalizeOrderID
- * Non-exhaustive integration tests to verify that order_id
- * normalization works as expected with different settings and
- * conditions in theGlobalCollect adapter
- * @covers GatewayAdapter::normalizeOrderID
- */
- public function testNormalizeOrderID() {
- $init = $this->initial_vars;
- unset( $init['order_id'] );
-
- //no order_id from anywhere, explicit no generate
- $gateway = $this->getFreshGatewayObject( $init, array (
'order_id_meta' => array ( 'generate' => FALSE ) ) );
- $this->assertFalse( $gateway->getOrderIDMeta( 'generate' ),
'The order_id meta generate setting override is not working properly. Deferred
order_id generation may be broken.' );
- $this->assertNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), 'Failed asserting that an absent order id is left as null, when
not generating our own' );
-
- //no order_id from anywhere, explicit generate
- $gateway = $this->getFreshGatewayObject( $init, array (
'order_id_meta' => array ( 'generate' => TRUE ) ) );
- $this->assertTrue( $gateway->getOrderIDMeta( 'generate' ), 'The
order_id meta generate setting override is not working properly. Self order_id
generation may be broken.' );
- $this->assertInternalType( 'numeric',
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'Generated order_id is not
numeric, which it should be for GlobalCollect' );
-
- $_GET['order_id'] = '55555';
- $_SESSION['Donor']['order_id'] = '44444';
-
- //conflicting order_id in $GET and $SESSION, default GC
generation
- $gateway = $this->getFreshGatewayObject( $init );
- $this->assertEquals( '55555',
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is
preferring session data over the $_GET. Session should be secondary.' );
-
- //conflicting order_id in $GET and $SESSION, garbage data in
$_GET, default GC generation
- $_GET['order_id'] = 'nonsense!';
- $gateway = $this->getFreshGatewayObject( $init );
- $this->assertEquals( '44444',
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is not
ignoring nonsensical order_id candidates' );
-
- unset( $_GET['order_id'] );
- //order_id in $SESSION, default GC generation
- $gateway = $this->getFreshGatewayObject( $init );
- $this->assertEquals( '44444',
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is not
recognizing the session order_id' );
-
- $_POST['order_id'] = '33333';
- //conflicting order_id in $_POST and $SESSION, default GC
generation
- $gateway = $this->getFreshGatewayObject( $init );
- $this->assertEquals( '33333',
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is
preferring session data over the $_POST. Session should be secondary.' );
-
- $init['order_id'] = '22222';
- //conflicting order_id in init data, $_POST and $SESSION,
explicit GC generation, batch mode
- $gateway = $this->getFreshGatewayObject( $init, array (
'order_id_meta' => array ( 'generate' => TRUE ), 'batch_mode' => TRUE, ) );
- $this->assertEquals( $init['order_id'],
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'Failed asserting that an
extrenally provided order id is being honored in batch mode' );
-
- //make sure that decimal numbers are rejected by GC. Should be
a toss and regen
- $init['order_id'] = '2143.0';
- unset( $_POST['order_id'] );
- unset( $_SESSION['Donor']['order_id'] );
- //conflicting order_id in init data, $_POST and $SESSION,
explicit GC generation, batch mode
- $gateway = $this->getFreshGatewayObject( $init, array (
'order_id_meta' => array ( 'generate' => TRUE, 'disallow_decimals' => TRUE ),
'batch_mode' => TRUE, ) );
- $this->assertNotEquals( $init['order_id'],
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'Failed assering that a
decimal order_id was regenerated, when disallow_decimals is true' );
- }
-
- /**
- * Non-exhaustive integration tests to verify that order_id, when in
- * self-generation mode, won't regenerate until it is told to.
- * @covers GatewayAdapter::normalizeOrderID
- * @covers GatewayAdapter::regenerateOrderID
- */
- function testStickyGeneratedOrderID() {
- $init = $this->initial_vars;
- unset( $init['order_id'] );
-
- //no order_id from anywhere, explicit generate
- $gateway = $this->getFreshGatewayObject( $init, array (
'order_id_meta' => array ( 'generate' => TRUE ) ) );
- $this->assertNotNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), 'Generated order_id is null. The rest of this test is broken.' );
- $original_order_id = $gateway->getData_Unstaged_Escaped(
'order_id' );
-
- $gateway->normalizeOrderID();
- $this->assertEquals( $original_order_id,
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'Re-normalized order_id has
changed without explicit regeneration.' );
-
- //this might look a bit strange, but we need to be able to
generate valid order_ids without making them stick to anything.
- $gateway->generateOrderID();
- $this->assertEquals( $original_order_id,
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'function generateOrderID
auto-changed the selected order ID. Not cool.' );
-
- $gateway->regenerateOrderID();
- $this->assertNotEquals( $original_order_id,
$gateway->getData_Unstaged_Escaped( 'order_id' ), 'Re-normalized order_id has
not changed, after explicit regeneration.' );
- }
-
- /**
- * Integration test to verify that order_id can be retrieved from
- * performing an INSERT_ORDERWITHPAYMENT.
- */
- function testOrderIDRetrieval() {
- $init = $this->getDonorTestData();
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
-
- //no order_id from anywhere, explicit generate
- $gateway = $this->getFreshGatewayObject( $init, array (
'order_id_meta' => array ( 'generate' => FALSE ) ) );
- $this->assertNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), 'Ungenerated order_id is not null. The rest of this test is
broken.' );
-
- $gateway->do_transaction( 'INSERT_ORDERWITHPAYMENT' );
-
- $this->assertNotNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), 'No order_id was retrieved from INSERT_ORDERWITHPAYMENT' );
- }
-
- /**
- * Just run the GET_ORDERSTATUS transaction and make sure we load the
data
- */
- function testGetOrderStatus() {
- $init = $this->getDonorTestData();
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['email'] = '[email protected]';
-
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->do_transaction( 'GET_ORDERSTATUS' );
-
- $data = $gateway->getTransactionData();
-
- $this->assertEquals( 'N', $data['CVVRESULT'], 'CVV Result not
loaded from XML response' );
- }
-
- /**
- * We should skip the API call if we're already suspicious
- */
- function testGetOrderStatusSkipsIfFail() {
- DonationInterface_FraudFiltersTestCase::setupFraudMaps();
-
- $init = $this->getDonorTestData();
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['email'] = '[email protected]'; //configured as a
fraudy domain
-
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->do_transaction( 'GET_ORDERSTATUS' );
-
- $data = $gateway->getTransactionData();
-
- $this->assertEquals( null, $data['CVVRESULT'], 'preprocess
should stop API call if fraud detected' );
- }
-
- /**
- * Ensure the Confirm_CreditCard transaction prefers CVVRESULT from the
XML
- * over any value from the querystring
- */
- function testConfirmCreditCardPrefersXmlCvv() {
- $init = $this->getDonorTestData();
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['email'] = '[email protected]';
-
- $this->setMwGlobals( 'wgRequest',
- new FauxRequest( array( 'CVVRESULT' => 'M' ), false ) );
-
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->do_transaction( 'Confirm_CreditCard' );
-
- $this->assertEquals( 'N',
$gateway->getData_Unstaged_Escaped('cvv_result'), 'CVV Result not taken from
XML response' );
- }
-
- /**
- * If querystring and XML have different CVVRESULT, that's awfully fishy
- */
- function testConfirmCreditCardFailsOnCvvResultConflict() {
- $init = $this->getDonorTestData();
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['email'] = '[email protected]';
-
- $this->setMwGlobals( 'wgRequest',
- new FauxRequest( array( 'CVVRESULT' => 'M' ), false ) );
-
- $gateway = $this->getFreshGatewayObject( $init );
-
- $result = $gateway->do_transaction( 'Confirm_CreditCard' );
-
- $this->assertFalse( $result['status'], 'Credit card should fail
if querystring and XML have different CVVRESULT' );
- }
-
- /**
- * testDefineVarMap
- *
- * This is tested with a bank transfer from Spain.
- *
- * @covers GlobalCollectAdapter::__construct
- * @covers GlobalCollectAdapter::defineVarMap
- */
- public function testDefineVarMap() {
-
- $gateway = $this->getFreshGatewayObject( $this->initial_vars );
-
- $var_map = array(
- 'ORDERID' => 'order_id',
- 'AMOUNT' => 'amount',
- 'CURRENCYCODE' => 'currency_code',
- 'LANGUAGECODE' => 'language',
- 'COUNTRYCODE' => 'country',
- 'MERCHANTREFERENCE' => 'contribution_tracking_id',
- 'RETURNURL' => 'returnto',
- 'IPADDRESS' => 'server_ip',
- 'ISSUERID' => 'issuer_id',
- 'PAYMENTPRODUCTID' => 'payment_product',
- 'CVV' => 'cvv',
- 'EXPIRYDATE' => 'expiration',
- 'CREDITCARDNUMBER' => 'card_num',
- 'FIRSTNAME' => 'fname',
- 'SURNAME' => 'lname',
- 'STREET' => 'street',
- 'CITY' => 'city',
- 'STATE' => 'state',
- 'ZIP' => 'zip',
- 'EMAIL' => 'email',
- 'ACCOUNTHOLDER' => 'account_holder',
- 'ACCOUNTNAME' => 'account_name',
- 'ACCOUNTNUMBER' => 'account_number',
- 'ADDRESSLINE1E' => 'address_line_1e',
- 'ADDRESSLINE2' => 'address_line_2',
- 'ADDRESSLINE3' => 'address_line_3',
- 'ADDRESSLINE4' => 'address_line_4',
- 'ATTEMPTID' => 'attempt_id',
- 'AUTHORISATIONID' => 'authorization_id',
- 'BANKACCOUNTNUMBER' => 'bank_account_number',
- 'BANKAGENZIA' => 'bank_agenzia',
- 'BANKCHECKDIGIT' => 'bank_check_digit',
- 'BANKCODE' => 'bank_code',
- 'BANKFILIALE' => 'bank_filiale',
- 'BANKNAME' => 'bank_name',
- 'BRANCHCODE' => 'branch_code',
- 'COUNTRYCODEBANK' => 'country_code_bank',
- 'COUNTRYDESCRIPTION' => 'country_description',
- 'CUSTOMERBANKCITY' => 'customer_bank_city',
- 'CUSTOMERBANKSTREET' => 'customer_bank_street',
- 'CUSTOMERBANKNUMBER' => 'customer_bank_number',
- 'CUSTOMERBANKZIP' => 'customer_bank_zip',
- 'DATECOLLECT' => 'date_collect',
- 'DESCRIPTOR' => 'descriptor',
- 'DIRECTDEBITTEXT' => 'direct_debit_text',
- 'DOMICILIO' => 'domicilio',
- 'EFFORTID' => 'effort_id',
- 'IBAN' => 'iban',
- 'IPADDRESSCUSTOMER' => 'user_ip',
- 'PAYMENTREFERENCE' => 'payment_reference',
- 'PROVINCIA' => 'provincia',
- 'SPECIALID' => 'special_id',
- 'SWIFTCODE' => 'swift_code',
- 'TRANSACTIONTYPE' => 'transaction_type',
- 'FISCALNUMBER' => 'fiscal_number',
- );
-
- $this->assertEquals( $var_map, $gateway->getVarMap() );
- }
-
- public function testLanguageStaging() {
- $options = $this->getDonorTestData( 'NO' );
- $options['payment_method'] = 'cc';
- $options['payment_submethod'] = 'visa';
- $gateway = $this->getFreshGatewayObject( $options );
-
- $gateway->_stageData();
-
- $this->assertEquals( $gateway->_getData_Staged( 'language' ),
'no', "'NO' donor's language was inproperly set. Should be 'no'" );
- }
-
- /**
- * Tests to make sure that certain error codes returned from GC will or
- * will not create payments error loglines.
- */
- function testCCLogsOnGatewayError() {
- $init = $this->getDonorTestData( 'US' );
- unset( $init['order_id'] );
- $init['ffname'] = 'cc-vmad';
-
- //this should not throw any payments errors: Just an invalid
card.
- $gateway = $this->getFreshGatewayObject( $init );
- $gateway->setDummyGatewayResponseCode( '430285' );
- $gateway->do_transaction( 'GET_ORDERSTATUS' );
- $this->verifyNoLogErrors( $gateway );
-
- //Now test one we want to throw a payments error
- $gateway = $this->getFreshGatewayObject( $init );
- $gateway->setDummyGatewayResponseCode( '21000050' );
- $gateway->do_transaction( 'GET_ORDERSTATUS' );
- $logline = $this->getGatewayLogMatches( $gateway, LOG_ERR,
'/Investigation required!/' );
- $this->assertType( 'string', $logline, 'GC Error 21000050 is
not generating the expected payments log error' );
- }
-
- /**
- * Tests to make sure that certain error codes returned from GC will
- * trigger order cancellation, even if retryable errors also exist.
- * @dataProvider mcNoRetryCodeProvider
- */
- public function testNoMastercardFinesForRepeatOnBadCodes( $code ) {
- $init = $this->getDonorTestData( 'US' );
- unset( $init['order_id'] );
- $init['ffname'] = 'cc-vmad';
- //Make it not look like an orphan
- $this->setMwGlobals( 'wgRequest',
- new FauxRequest( array(
- 'CVVRESULT' => 'M',
- 'AVSRESULT' => '0'
- ), false ) );
-
- //Toxic card should not retry, even if there's an order id
collision
- $gateway = $this->getFreshGatewayObject( $init );
- $gateway->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!" );
- $this->assertEquals( 1, count( $gateway->limbo_stomps ),
"Gateway sent no limbostomps for code $code! Should have sent an antimessage!"
);
- $this->assertEquals( true, $gateway->limbo_stomps[0], "Gateway
sent wrong stomp message for code $code! Should have sent an antimessage!" );
- }
-}
->>>>>>> BRANCH (5e90d5 Add IP spanking for shady cards to Worldpay)
diff --git a/tests/DonationInterfaceTestCase.php
b/tests/DonationInterfaceTestCase.php
deleted file mode 100644
index 9ee0f88..0000000
--- a/tests/DonationInterfaceTestCase.php
+++ /dev/null
@@ -1,600 +0,0 @@
-<<<<<<< HEAD (64ab77 Merge branch 'master' into deploy-payments_1.22)
-=======
-<?php
-/**
- * Wikimedia Foundation
- *
- * LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-/**
- * @group Fundraising
- * @group QueueHandling
- * @group ClassMethod
- * @group ListenerAdapter
- *
- * @category UnitTesting
- * @package Fundraising_QueueHandling
- */
-abstract class DonationInterfaceTestCase extends MediaWikiTestCase {
- protected $backupGlobalsBlacklist = array(
- 'wgHooks',
- );
-
- /**
- * Returns an array of the vars we expect to be set before people hit
payments.
- * @var array
- */
- public $initial_vars = array (
- 'ffname' => 'testytest',
- 'referrer' => 'www.yourmom.com', //please don't go there.
- 'currency_code' => 'USD',
- );
-
- /**
- * This will be set by a test method with the adapter object.
- *
- * @var GatewayAdapter $gatewayAdapter
- */
- protected $gatewayAdapter;
-
- /**
- * @param $name string The name of the test case
- * @param $data array Any parameters read from a dataProvider
- * @param $dataName string|int The name or index of the data set
- */
- public function __construct( $name = null, array $data = array(),
$dataName = '' ) {
-
- //Just in case you got here without running the configuration...
- global $wgDonationInterfaceTestMode;
- $wgDonationInterfaceTestMode = true;
-
- $adapterclass = TESTS_ADAPTER_DEFAULT;
- $this->testAdapterClass = $adapterclass;
-
- parent::__construct( $name, $data, $dataName );
- }
-
- protected function setUp() {
- parent::setUp();
- }
-
- protected function tearDown() {
- $this->resetAllEnv();
- parent::tearDown();
- }
-
- /**
- * buildRequestXmlForGlobalCollect
- *
- * @todo
- * - there are many cases to this that need to be developed.
- * - Do not consider this a complete test!
- *
- * @covers GatewayAdapter::__construct
- * @covers GatewayAdapter::setCurrentTransaction
- * @covers GatewayAdapter::buildRequestXML
- */
- public function buildRequestXmlForGlobalCollect( $optionsForTestData,
$options ) {
-
- global $wgDonationInterfaceTest;
-
- $wgDonationInterfaceTest = true;
-
- $this->gatewayAdapter = $this->getFreshGatewayObject( $options
);
-
-
$this->gatewayAdapter->setCurrentTransaction('INSERT_ORDERWITHPAYMENT');
-
- $request = trim( $this->gatewayAdapter->_buildRequestXML() );
-
- $expected = $this->getExpectedXmlRequestForGlobalCollect(
$optionsForTestData, $options );
-
- $this->assertEquals( $expected, $request, 'The constructed XML
for payment_method [' . $optionsForTestData['payment_method'] . '] and
payment_submethod [' . $optionsForTestData['payment_submethod'] . '] does not
match our expected request.' );
- }
-
- /**
- *
- * @param string $country The country we want the test user to be from.
- * @return array Donor data to use
- * @throws MWException when there is no data available for the
requested country
- */
- public function getDonorTestData( $country = '' ) {
- $donortestdata = array (
- 'US' => array ( //default
- 'city' => 'San Francisco',
- 'state' => 'CA',
- 'zip' => '94105',
- 'currency_code' => 'USD',
- 'street' => '123 Fake Street',
- 'fname' => 'Firstname',
- 'lname' => 'Surname',
- 'amount' => '1.55',
- 'language' => 'en',
- ),
- 'ES' => array (
- 'city' => 'Barcelona',
- 'state' => 'XX',
- 'zip' => '0',
- 'currency_code' => 'EUR',
- 'street' => '123 Calle Fake',
- 'fname' => 'Nombre',
- 'lname' => 'Apellido',
- 'amount' => '1.55',
- 'language' => 'es',
- ),
- 'NO' => array (
- 'city' => 'Oslo',
- 'state' => 'XX',
- 'zip' => '0',
- 'currency_code' => 'EUR',
- 'street' => '123 Fake Gate',
- 'fname' => 'Fornavn',
- 'lname' => 'Etternavn',
- 'amount' => '1.55',
- 'language' => 'no',
- ),
- 'FR' => array (
- 'city' => 'Versailles',
- 'state' => 'XX',
- 'zip' => '0',
- 'currency_code' => 'EUR',
- 'street' => '123 Rue Faux',
- 'fname' => 'Prénom',
- 'lname' => 'Nom',
- 'amount' => '1.55',
- 'language' => 'fr',
- ),
- 'NL' => array (
- 'city' => 'Amsterdam',
- 'state' => 'XX',
- 'zip' => '0',
- 'currency_code' => 'EUR',
- 'street' => '123 nep straat',
- 'fname' => 'Voornaam',
- 'lname' => 'Achternaam',
- 'amount' => '1.55',
- 'language' => 'nl',
- ),
- 'BE' => array (
- 'city' => 'Antwerp',
- 'state' => 'XX',
- 'zip' => '0',
- 'currency_code' => 'EUR',
- 'street' => '123 nep straat',
- 'fname' => 'Voornaam',
- 'lname' => 'Achternaam',
- 'amount' => '1.55',
- 'language' => 'nl',
- ),
- 'IT' => array (
- 'city' => 'Torino',
- 'state' => 'TO',
- 'zip' => '10123',
- 'currency_code' => 'EUR',
- 'street' => 'Via Falso 123',
- 'fname' => 'Nome',
- 'lname' => 'Cognome',
- 'amount' => '1.55',
- 'language' => 'it',
- ),
- 'CA' => array (
- 'city' => 'Saskatoon',
- 'state' => 'SK',
- 'zip' => 'S7K 0J5',
- 'currency_code' => 'CAD',
- 'street' => '123 Fake Street',
- 'fname' => 'Firstname',
- 'lname' => 'Surname',
- 'amount' => '1.55',
- 'language' => 'en',
- ),
- );
- //default to US
- if ( $country === '' ) {
- $country = 'US';
- }
-
- if ( array_key_exists( $country, $donortestdata ) ) {
- $donortestdata = array_merge( $this->initial_vars,
$donortestdata[$country] );
- $donortestdata['country'] = $country;
- return $donortestdata;
- }
- throw new MWException( __FUNCTION__ . ": No donor data for
country '$country'" );
- }
-
- /**
- * Supported languages for Belgium
- */
- public function belgiumLanguageProvider() {
- return array(
- array( 'nl' ),
- array( 'de' ),
- array( 'fr' ),
- );
- }
-
- /**
- * Supported languages for Canada
- */
- public function canadaLanguageProvider() {
- return array(
- array( 'en' ),
- array( 'fr' ),
- );
- }
-
- /**
- * Transaction codes for GC and GC orphan adapters not to be retried
- * on pain of $1000+ fines by MasterCard
- */
- public function mcNoRetryCodeProvider() {
- return array(
- array( '430260' ),
- array( '430306' ),
- array( '430330' ),
- array( '430354' ),
- array( '430357' ),
- );
- }
-
- /**
- * Get the expected XML request from GlobalCollect
- *
- * @param $optionsForTestData
- * @param array $options
- * @return string The expected XML request
- */
- public function getExpectedXmlRequestForGlobalCollect(
$optionsForTestData, $options = array() ) {
- global $wgRequest, $wgServer, $wgArticlePath,
$wgDonationInterfaceThankYouPage;
-
- $orderId = $this->gatewayAdapter->getData_Unstaged_Escaped(
'order_id' );
- $merchantref = $this->gatewayAdapter->_getData_Staged(
'contribution_tracking_id' );
- //@TODO: WHY IN THE NAME OF ZARQUON are we building XML in a
STRING format here?!?!?!!!1one1!?. Great galloping galumphing giraffes.
- $expected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
- $expected .= '<XML>';
- $expected .= '<REQUEST>';
- $expected .=
'<ACTION>INSERT_ORDERWITHPAYMENT</ACTION>';
- $expected .= '<META><MERCHANTID>' .
$this->gatewayAdapter->getGlobal( 'MerchantID' ) . '</MERCHANTID>';
-
- if ( isset( $wgRequest ) ) {
- $expected .= '<IPADDRESS>' .
$wgRequest->getIP() . '</IPADDRESS>';
- }
-
- $expected .= '<VERSION>1.0</VERSION>';
- $expected .= '</META>';
- $expected .= '<PARAMS>';
- $expected .= '<ORDER>';
- $expected .= '<ORDERID>' . $orderId
. '</ORDERID>';
- $expected .= '<AMOUNT>' .
$options['amount'] * 100 . '</AMOUNT>';
- $expected .= '<CURRENCYCODE>' .
$options['currency_code'] . '</CURRENCYCODE>';
- $expected .= '<LANGUAGECODE>' .
$options['language'] . '</LANGUAGECODE>';
- $expected .= '<COUNTRYCODE>' .
$options['country'] . '</COUNTRYCODE>';
- $expected .= '<MERCHANTREFERENCE>' . $merchantref .
'</MERCHANTREFERENCE>';
-
- if ( isset( $wgRequest ) ) {
- $expected .= '<IPADDRESSCUSTOMER>' .
$wgRequest->getIP() . '</IPADDRESSCUSTOMER>';
- }
-
- $expected .= '<EMAIL>' . TESTS_EMAIL
. '</EMAIL>';
- $expected .= '</ORDER>';
- $expected .= '<PAYMENT>';
- $expected .= '<PAYMENTPRODUCTID>' .
$optionsForTestData['payment_product_id'] . '</PAYMENTPRODUCTID>';
- $expected .= '<AMOUNT>' .
$options['amount'] * 100 . '</AMOUNT>';
- $expected .= '<CURRENCYCODE>' .
$options['currency_code'] . '</CURRENCYCODE>';
- $expected .= '<LANGUAGECODE>' .
$options['language'] . '</LANGUAGECODE>';
- $expected .= '<COUNTRYCODE>' .
$options['country'] . '</COUNTRYCODE>';
- $expected .=
'<HOSTEDINDICATOR>1</HOSTEDINDICATOR>';
- $expected .= '<RETURNURL>' .
$wgDonationInterfaceThankYouPage . '/' . $options['language'] . '</RETURNURL>';
- $expected .=
'<AUTHENTICATIONINDICATOR>0</AUTHENTICATIONINDICATOR>';
- $expected .= '<FIRSTNAME>' .
$options['fname'] . '</FIRSTNAME>';
- $expected .= '<SURNAME>' .
$options['lname'] . '</SURNAME>';
- $expected .= '<STREET>' .
$options['street'] . '</STREET>';
- $expected .= '<CITY>' .
$options['city'] . '</CITY>';
- $expected .= '<STATE>' .
$options['state'] . '</STATE>';
- $expected .= '<ZIP>' .
$options['zip'] . '</ZIP>';
- $expected .= '<EMAIL>' . TESTS_EMAIL . '</EMAIL>';
-
- // Set the issuer id if it is passed.
- if ( isset( $optionsForTestData['descriptor'] ) ) {
- $expected .= '<DESCRIPTOR>' .
$optionsForTestData['descriptor'] . '</DESCRIPTOR>';
- }
-
- // Set the issuer id if it is passed.
- if ( isset( $optionsForTestData['issuer_id'] ) ) {
- $expected .= '<ISSUERID>' .
$optionsForTestData['issuer_id'] . '</ISSUERID>';
- }
-
-
- // If we're doing Direct Debit...
- //@TODO: go ahead and split this out into a "Get the direct
debit I_OWP XML block function" the second this gets even slightly annoying.
- if ( $optionsForTestData['payment_method'] === 'dd' ) {
- $expected .= '<DATECOLLECT>' . gmdate( 'Ymd' ) .
'</DATECOLLECT>'; //is this cheating? Probably.
- $expected .= '<ACCOUNTNAME>' .
$optionsForTestData['account_name'] . '</ACCOUNTNAME>';
- $expected .= '<ACCOUNTNUMBER>' .
$optionsForTestData['account_number'] . '</ACCOUNTNUMBER>';
- $expected .= '<BANKCODE>' .
$optionsForTestData['bank_code'] . '</BANKCODE>';
- $expected .= '<BRANCHCODE>' .
$optionsForTestData['branch_code'] . '</BRANCHCODE>';
- $expected .= '<BANKCHECKDIGIT>' .
$optionsForTestData['bank_check_digit'] . '</BANKCHECKDIGIT>';
- $expected .= '<DIRECTDEBITTEXT>' .
$optionsForTestData['direct_debit_text'] . '</DIRECTDEBITTEXT>';
- }
-
- $expected .= '</PAYMENT>';
- $expected .= '</PARAMS>';
- $expected .= '</REQUEST>';
- $expected .= '</XML>';
-
- return $expected;
-
- }
-
- /**
- * Get a fresh gateway object of the type specified in the variable
- * $this->testAdapterClass.
- * @param array $external_data If you want to shoehorn in some external
- * data, do that here.
- * @param array $setup_hacks An array of things that override stuff in
- * the constructor of the gateway object that I can't get to without
- * refactoring the whole thing. @TODO: Refactor the gateway adapter
- * constructor.
- * @return \class The new relevant gateway adapter object.
- */
- function getFreshGatewayObject( $external_data = null, $setup_hacks =
array() ) {
- $p1 = null;
- if ( !is_null( $external_data ) ) {
- $p1 = array (
- 'external_data' => $external_data,
- );
- }
-
- if ( $setup_hacks ) {
- if ( !is_null( $p1 ) ) {
- $p1 = array_merge( $p1, $setup_hacks );
- } else {
- $p1 = $setup_hacks;
- }
- }
-
- $class = $this->testAdapterClass;
- $gateway = new $class( $p1 );
-
- // FIXME: Find a more elegant way to hackity hacken hack.
- // We want to override any define- functions with hacky values.
- foreach ( $setup_hacks as $field => $value ) {
- $gateway->$field = $value;
- }
-
- return $gateway;
- }
-
- function resetAllEnv() {
- $_SESSION = array ( );
- $_GET = array ( );
- $_POST = array ( );
-
- $_SERVER = array ( );
- $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
- $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME;
- $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME;
- $_SERVER['SCRIPT_NAME'] = __FILE__;
- }
-
- /**
- * Instantiates the $special_page_class with supplied $initial_vars,
- * yoinks the html output from the output buffer, loads that into a
- * DomDocument and performs asserts on the results per the checks
- * supplied in $perform_these_checks.
- * Optional: Asserts that the gateway has logged nothing at ERROR level.
- *
- * @param class $special_page_class A testing descendant of GatewayPage
- * @param array $initial_vars Array that will be loaded straight into a
- * test version of $wgRequest.
- * @param array $perform_these_checks Array of checks to perform in the
- * following format:
- *
$perform_these_checks[$element_id][$check_to_perform][$expected_result]
- * So far, $check_to_perform can be either 'nodename' or 'innerhtml'
- * @param boolean $fail_on_log_errors When true, this will fail the
- * current test if there are entries in the gateway's error log.
- */
- function verifyFormOutput( $special_page_class, $initial_vars,
$perform_these_checks, $fail_on_log_errors = false ) {
- // Nasty hack to clear output from any previous tests.
- $mainContext = RequestContext::getMain();
- $newOutput = new OutputPage( $mainContext );
- $newRequest = new TestingRequest( $initial_vars, false );
- $mainContext->setRequest( $newRequest );
- $mainContext->setOutput( $newOutput );
-
- $globals = array (
- 'wgRequest' => $newRequest,
- 'wgTitle' => Title::newFromText( 'nonsense is
apparently fine' ),
- 'wgOut' => $newOutput,
- );
-
- $this->setMwGlobals( $globals );
-
- $this->setLanguage( $initial_vars['language'] );
-
- ob_start();
- $formpage = new $special_page_class();
- $formpage->execute( NULL );
- $formpage->getOutput()->output();
- $form_html = ob_get_contents();
- ob_end_clean();
-
- // In the event that something goes crazy, uncomment the next
line for much easier local debugging
- // file_put_contents( '/tmp/xmlout.txt', $form_html );
-
- if ( $fail_on_log_errors ) {
- $this->verifyNoLogErrors( $formpage->adapter );
- }
-
- $dom_thingy = new DomDocument();
- //// DEBUGGING, foo
- // if (property_exists($this, 'FOO')) {
- //
error_log(var_export($formpage->getRequest()->response()->getheader('Location'),
true));
- // error_log(var_export($form_html, true));
- // }
-
- if ( $form_html ) {
- // p.s. i'm SERIOUS about the character encoding.
- $dom_thingy->loadHTML( '<?xml encoding="UTF-8">' .
$form_html );
- $dom_thingy->encoding = 'UTF-8';
- }
-
- foreach ( $perform_these_checks as $id => $checks ) {
- if ( $id == 'headers' ) {
- foreach ( $checks as $name => $expected ) {
- $actual =
$formpage->getRequest()->response()->getheader( $name );
- $this->performCheck( $actual,
$expected, "header '$name'");
- break;
- }
- continue;
- }
- unset( $perform_these_checks['headers'] );
-
- $input_node = $dom_thingy->getElementById( $id );
- $this->assertNotNull( $input_node, "Couldn't find the
'$id' element" );
- foreach ( $checks as $name => $expected ) {
- switch ( $name ) {
- case 'nodename':
- $this->performCheck(
$input_node->nodeName, $expected, "name of node with id '$id'");
- break;
- case 'innerhtml':
- $this->performCheck(
self::getInnerHTML( $input_node ), $expected, "innerHTML of node '$id'");
- break;
- case 'innerhtmlmatches':
- $this->assertEquals( 1,
preg_match( $expected, self::getInnerHTML( $input_node ) ), "Value of the node
with id '$id' does not match pattern '$expected'. It has value " .
self::getInnerHTML( $input_node ) );
- break;
- case 'value':
- $this->performCheck(
$input_node->getAttribute('value'), $expected, "value of node with id '$id'");
- break;
- case 'selected':
- $selected = null;
- if ( $input_node->nodeName ===
'select' ) {
- $options =
$input_node->getElementsByTagName( 'option' );
- foreach ( $options as
$option ) {
- if (
$option->hasAttribute( 'selected' ) ) {
-
$selected = $option->getAttribute( 'value' );
- break;
- }
- }
- $this->performCheck(
$selected, $expected, "selected option value of node with id '$id'");
- } else {
- $this->fail( "Attempted
to test for selected value on non-select node, id '$id'" );
- }
- break;
- }
- }
- }
-
- //because do_transaction is totally expected to leave session
artifacts...
-// $wgRequest = new FauxRequest();
- }
-
- /**
- * Performs some sort of assertion on a value.
- *
- * @param string $value the value to test
- * @param string|callable $check
- * if $check is callable, it is called with argument $value
- * otherwise, $value is asserted to be equal to $check
- * @param string $label identifies the value in assertion failures
- * @return void
- */
- function performCheck( $value, $check, $label = 'Tested value' ) {
- if ( is_callable( $check ) ) {
- $check( $value );
- return;
- }
- $this->assertEquals( $check, $value, "Expected $label to be
$check, found $value instead.");
- }
- /**
- * Asserts that $gateway has no log entries of LOG_ERR or worse.
- * @param object $gateway The gateway to check
- */
- function verifyNoLogErrors( $gateway ) {
- $log = $gateway->testlog;
-
- $this->assertTrue( is_array( $log ), "Missing the adapter
testlog" );
-
- //for our purposes, an "error" is LOG_ERR or less.
- $checklogs = array (
- LOG_ERR => "Oops: We've got LOG_ERRors.",
- LOG_CRIT => "Critical errors!",
- LOG_ALERT => "Log Alerts!",
- LOG_EMERG => "Logs says the servers are actually on
fire.",
- );
-
- $message = false;
- foreach ( $checklogs as $level => $levelmessage ) {
- if ( array_key_exists( $level, $log ) ) {
- $message = $levelmessage . ' ' . print_r(
$log[$level], true ) . "\n";
- }
- }
-
- $this->assertFalse( $message, $message ); //ha
- }
-
- /**
- * Finds a relevant line/lines in a gateway's log array
- * @param test adapter $gateway The gateway that should have the log
line you're looking for.
- * @param integer $log_level A standard level that the line should...
get logged at.
- * @param string $match A regex to match against the log lines.
- * @return mixed The full log line that matches the $match, an array if
there were multiples, or false if none were found.
- */
- public function getGatewayLogMatches( $gateway, $log_level, $match ) {
- $log = $gateway->testlog;
- if ( !array_key_exists( $log_level, $log ) ) {
- return false;
- }
-
- $return = array ( );
- foreach ( $log[$log_level] as $line ) {
- if ( preg_match( $match, $line ) ) {
- $return[] = $line;
- }
- }
-
- if ( empty( $return ) ) {
- return false;
- }
- if ( sizeof( $return ) === 1 ) {
- return $return[0];
- }
- return $return;
- }
-
- /**
- * Set global language for the duration of the test
- *
- * @param string $language language code to force
- */
- protected function setLanguage( $language ) {
- $newLang = new TestingLanguage();
- //this should be more robust, but... might have to work for now.
- $newLang->forceLang( $language );
-
- $this->setMwGlobals( array (
- 'wgLang' => $newLang,
- ) );
- }
-
- static function getInnerHTML( $node ) {
- $innerHTML = '';
- $children = $node->childNodes;
- foreach ( $children as $child ) {
- $innerHTML .= $child->ownerDocument->saveXML( $child );
- }
- return $innerHTML;
- }
-}
->>>>>>> BRANCH (5e90d5 Add IP spanking for shady cards to Worldpay)
diff --git
a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430260.testresponse
b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430260.testresponse
deleted file mode 100644
index 2e9ffd8..0000000
--- a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430260.testresponse
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version = "1.0"?>
-<!-- 'Call security' error and dupe order id. Should not be retried, even
though
-there is a recoverable error. Checking the case with recoverable first -->
-<XML>
- <REQUEST>
- <ACTION>GET_ORDERSTATUS</ACTION>
- <META>
- <MERCHANTID>test</MERCHANTID>
- <IPADDRESS>127.0.0.1</IPADDRESS>
- <VERSION>2.0</VERSION>
- </META>
- <PARAMS>
- <ORDER>
- <ORDERID>1234567890</ORDERID>
- </ORDER>
- </PARAMS>
- <RESPONSE>
- <RESULT>OK</RESULT>
- <META>
- <REQUESTID>1234567</REQUESTID>
-
<RESPONSEDATETIME>20140704021818</RESPONSEDATETIME>
- </META>
- <STATUS>
- <STATUSDATE>20140704021814</STATUSDATE>
- <PAYMENTMETHODID>1</PAYMENTMETHODID>
-
<MERCHANTREFERENCE>14222.39313</MERCHANTREFERENCE>
- <FRAUDRESULT>N</FRAUDRESULT>
- <ATTEMPTID>1</ATTEMPTID>
- <PAYMENTREFERENCE>0</PAYMENTREFERENCE>
- <AMOUNT>155</AMOUNT>
- <AVSRESULT>0</AVSRESULT>
- <EXPIRYDATE>0714</EXPIRYDATE>
- <MERCHANTID>6570</MERCHANTID>
- <ORDERID>1234567890</ORDERID>
- <STATUSID>100</STATUSID>
-
<CREDITCARDNUMBER>************2105</CREDITCARDNUMBER>
- <EFFORTID>1</EFFORTID>
- <CVVRESULT>M</CVVRESULT>
- <CURRENCYCODE>USD</CURRENCYCODE>
- <PAYMENTPRODUCTID>3</PAYMENTPRODUCTID>
- <ERRORS>
- <ERROR>
- <TYPE>B</TYPE>
- <CODE>300620</CODE>
- <MESSAGE>300620 Duplicate Order
ID</MESSAGE>
- </ERROR>
- <ERROR>
- <TYPE>B</TYPE>
- <CODE>430260</CODE>
- <MESSAGE>430260 Call Security
Department</MESSAGE>
- </ERROR>
- </ERRORS>
- </STATUS>
- </RESPONSE>
- </REQUEST>
-</XML>
\ No newline at end of file
diff --git
a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430306.testresponse
b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430306.testresponse
deleted file mode 100644
index d464d06..0000000
--- a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430306.testresponse
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version = "1.0"?>
-<!--Expired card error and dupe order id. Should not be retried even though
-there is a recoverable error. Tests the case with the recoverable error last.
-->
-<XML>
- <REQUEST>
- <ACTION>GET_ORDERSTATUS</ACTION>
- <META>
- <MERCHANTID>test</MERCHANTID>
- <IPADDRESS>127.0.0.1</IPADDRESS>
- <VERSION>2.0</VERSION>
- </META>
- <PARAMS>
- <ORDER>
- <ORDERID>1234567890</ORDERID>
- </ORDER>
- </PARAMS>
- <RESPONSE>
- <RESULT>OK</RESULT>
- <META>
- <REQUESTID>1234567</REQUESTID>
-
<RESPONSEDATETIME>20140704021818</RESPONSEDATETIME>
- </META>
- <STATUS>
- <STATUSDATE>20140704021814</STATUSDATE>
- <PAYMENTMETHODID>1</PAYMENTMETHODID>
-
<MERCHANTREFERENCE>14222.39313</MERCHANTREFERENCE>
- <FRAUDRESULT>N</FRAUDRESULT>
- <ATTEMPTID>1</ATTEMPTID>
- <PAYMENTREFERENCE>0</PAYMENTREFERENCE>
- <AMOUNT>155</AMOUNT>
- <AVSRESULT>0</AVSRESULT>
- <EXPIRYDATE>0714</EXPIRYDATE>
- <MERCHANTID>6570</MERCHANTID>
- <ORDERID>1234567890</ORDERID>
- <STATUSID>100</STATUSID>
-
<CREDITCARDNUMBER>************2105</CREDITCARDNUMBER>
- <EFFORTID>1</EFFORTID>
- <CVVRESULT>M</CVVRESULT>
- <CURRENCYCODE>USD</CURRENCYCODE>
- <PAYMENTPRODUCTID>3</PAYMENTPRODUCTID>
- <ERRORS>
- <ERROR>
- <TYPE>B</TYPE>
- <CODE>430306</CODE>
- <MESSAGE>430306 Card
Expired</MESSAGE>
- </ERROR>
- <ERROR>
- <TYPE>B</TYPE>
- <CODE>300620</CODE>
- <MESSAGE>300620 Duplicate Order
ID</MESSAGE>
- </ERROR>
- </ERRORS>
- </STATUS>
- </RESPONSE>
- </REQUEST>
-</XML>
\ No newline at end of file
diff --git
a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430330.testresponse
b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430330.testresponse
deleted file mode 100644
index 42a6842..0000000
--- a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430330.testresponse
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version = "1.0"?>
-<!--Invalid card number. Should not be retried-->
-<XML>
- <REQUEST>
- <ACTION>GET_ORDERSTATUS</ACTION>
- <META>
- <MERCHANTID>test</MERCHANTID>
- <IPADDRESS>127.0.0.1</IPADDRESS>
- <VERSION>2.0</VERSION>
- </META>
- <PARAMS>
- <ORDER>
- <ORDERID>1234567890</ORDERID>
- </ORDER>
- </PARAMS>
- <RESPONSE>
- <RESULT>OK</RESULT>
- <META>
- <REQUESTID>1234567</REQUESTID>
-
<RESPONSEDATETIME>20140704021818</RESPONSEDATETIME>
- </META>
- <STATUS>
- <STATUSDATE>20140704021814</STATUSDATE>
- <PAYMENTMETHODID>1</PAYMENTMETHODID>
-
<MERCHANTREFERENCE>14222.39313</MERCHANTREFERENCE>
- <FRAUDRESULT>N</FRAUDRESULT>
- <ATTEMPTID>1</ATTEMPTID>
- <PAYMENTREFERENCE>0</PAYMENTREFERENCE>
- <AMOUNT>155</AMOUNT>
- <AVSRESULT>0</AVSRESULT>
- <EXPIRYDATE>0714</EXPIRYDATE>
- <MERCHANTID>6570</MERCHANTID>
- <ORDERID>1234567890</ORDERID>
- <STATUSID>100</STATUSID>
-
<CREDITCARDNUMBER>************2105</CREDITCARDNUMBER>
- <EFFORTID>1</EFFORTID>
- <CVVRESULT>M</CVVRESULT>
- <CURRENCYCODE>USD</CURRENCYCODE>
- <PAYMENTPRODUCTID>3</PAYMENTPRODUCTID>
- <ERRORS>
- <ERROR>
- <TYPE>B</TYPE>
- <CODE>430330</CODE>
- <MESSAGE>430330 Invalid Card
Number</MESSAGE>
- </ERROR>
- </ERRORS>
- </STATUS>
- </RESPONSE>
- </REQUEST>
-</XML>
\ No newline at end of file
diff --git
a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430354.testresponse
b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430354.testresponse
deleted file mode 100644
index 91b17ac..0000000
--- a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430354.testresponse
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version = "1.0"?>
-<!--Issuer unknown. Should not be retried-->
-<XML>
- <REQUEST>
- <ACTION>GET_ORDERSTATUS</ACTION>
- <META>
- <MERCHANTID>test</MERCHANTID>
- <IPADDRESS>127.0.0.1</IPADDRESS>
- <VERSION>2.0</VERSION>
- </META>
- <PARAMS>
- <ORDER>
- <ORDERID>1234567890</ORDERID>
- </ORDER>
- </PARAMS>
- <RESPONSE>
- <RESULT>OK</RESULT>
- <META>
- <REQUESTID>1234567</REQUESTID>
-
<RESPONSEDATETIME>20140704021818</RESPONSEDATETIME>
- </META>
- <STATUS>
- <STATUSDATE>20140704021814</STATUSDATE>
- <PAYMENTMETHODID>1</PAYMENTMETHODID>
-
<MERCHANTREFERENCE>14222.39313</MERCHANTREFERENCE>
- <FRAUDRESULT>N</FRAUDRESULT>
- <ATTEMPTID>1</ATTEMPTID>
- <PAYMENTREFERENCE>0</PAYMENTREFERENCE>
- <AMOUNT>155</AMOUNT>
- <AVSRESULT>0</AVSRESULT>
- <EXPIRYDATE>0714</EXPIRYDATE>
- <MERCHANTID>6570</MERCHANTID>
- <ORDERID>1234567890</ORDERID>
- <STATUSID>100</STATUSID>
-
<CREDITCARDNUMBER>************2105</CREDITCARDNUMBER>
- <EFFORTID>1</EFFORTID>
- <CVVRESULT>M</CVVRESULT>
- <CURRENCYCODE>USD</CURRENCYCODE>
- <PAYMENTPRODUCTID>3</PAYMENTPRODUCTID>
- <ERRORS>
- <ERROR>
- <TYPE>B</TYPE>
- <CODE>430354</CODE>
- <MESSAGE>430354 Issuer
Unknown</MESSAGE>
- </ERROR>
- </ERRORS>
- </STATUS>
- </RESPONSE>
- </REQUEST>
-</XML>
\ No newline at end of file
diff --git
a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430357.testresponse
b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430357.testresponse
deleted file mode 100644
index 137701d..0000000
--- a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_430357.testresponse
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version = "1.0"?>
-<!--Lost or stolen card. Should not be retried, and should be penalized in
-velocity filter.-->
-<XML>
- <REQUEST>
- <ACTION>GET_ORDERSTATUS</ACTION>
- <META>
- <MERCHANTID>test</MERCHANTID>
- <IPADDRESS>127.0.0.1</IPADDRESS>
- <VERSION>2.0</VERSION>
- </META>
- <PARAMS>
- <ORDER>
- <ORDERID>1234567890</ORDERID>
- </ORDER>
- </PARAMS>
- <RESPONSE>
- <RESULT>OK</RESULT>
- <META>
- <REQUESTID>1234567</REQUESTID>
-
<RESPONSEDATETIME>20140704021818</RESPONSEDATETIME>
- </META>
- <STATUS>
- <STATUSDATE>20140704021814</STATUSDATE>
- <PAYMENTMETHODID>1</PAYMENTMETHODID>
-
<MERCHANTREFERENCE>14222.39313</MERCHANTREFERENCE>
- <FRAUDRESULT>N</FRAUDRESULT>
- <ATTEMPTID>1</ATTEMPTID>
- <PAYMENTREFERENCE>0</PAYMENTREFERENCE>
- <AMOUNT>155</AMOUNT>
- <AVSRESULT>0</AVSRESULT>
- <EXPIRYDATE>0714</EXPIRYDATE>
- <MERCHANTID>6570</MERCHANTID>
- <ORDERID>1234567890</ORDERID>
- <STATUSID>100</STATUSID>
-
<CREDITCARDNUMBER>************2105</CREDITCARDNUMBER>
- <EFFORTID>1</EFFORTID>
- <CVVRESULT>M</CVVRESULT>
- <CURRENCYCODE>USD</CURRENCYCODE>
- <PAYMENTPRODUCTID>3</PAYMENTPRODUCTID>
- <ERRORS>
- <ERROR>
- <TYPE>B</TYPE>
- <CODE>430357</CODE>
- <MESSAGE>430357 Lost or Stolen
Card</MESSAGE>
- </ERROR>
- </ERRORS>
- </STATUS>
- </RESPONSE>
- </REQUEST>
-</XML>
\ No newline at end of file
diff --git a/tests/includes/test_gateway/test.adapter.php
b/tests/includes/test_gateway/test.adapter.php
deleted file mode 100644
index 8252925..0000000
--- a/tests/includes/test_gateway/test.adapter.php
+++ /dev/null
@@ -1,774 +0,0 @@
-<<<<<<< HEAD (64ab77 Merge branch 'master' into deploy-payments_1.22)
-=======
-<?php
-/**
- * Wikimedia Foundation
- *
- * LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-/**
- * A really dumb adapter.
- */
-class TestingGenericAdapter extends GatewayAdapter {
-
- public $errorsForRevalidate = array();
- public $revalidateCount = 0;
- public static $fakeGlobals = array();
-
- public function revalidate($check_not_empty = array()) {
- $fakeErrors =
$this->errorsForRevalidate[$this->revalidateCount];
- if ( $fakeErrors !== null ) {
- $this->revalidateCount++;
- $this->setValidationErrors( $fakeErrors );
- return empty( $fakeErrors );
- }
- return parent::revalidate($check_not_empty);
- }
-
- public function normalizeOrderID( $override = null, $dataObj = null ) {
- return '12345';
- }
-
- public static function getGlobal( $name ) {
- if ( array_key_exists( $name,
TestingGenericAdapter::$fakeGlobals ) ) {
- return TestingGenericAdapter::$fakeGlobals[$name];
- }
- return parent::getGlobal( $name );
- }
-
- public function defineAccountInfo() {
- }
-
- public function defineDataConstraints() {
- }
-
- public function defineErrorMap() {
- }
-
- public function defineOrderIDMeta() {
- }
-
- public function definePaymentMethods() {
- }
-
- public function defineReturnValueMap() {
- }
-
- public function defineStagedVars() {
- }
-
- public function defineTransactions() {
- }
-
- public function defineVarMap() {
- }
-
- public function getResponseData($response) {
- }
-
- public function getResponseErrors($response) {
- }
-
- public function getResponseStatus($response) {
- }
-
- public function processResponse($response, &$retryVars = null) {
- }
-
- public function setGatewayDefaults() {
- }
-
- public static function getCurrencies() {
- }
-
-}
-
-/**
- * TestingGlobalCollectAdapter
- *
- * TODO: Add dependency injection to the base class so we don't have to repeat
code here.
- */
-class TestingGlobalCollectAdapter extends GlobalCollectAdapter {
- public $testlog = array ( );
-
- public $curled = array ( );
-
- public $limbo_stomps = array ( );
-
- /**
- * Also set a useful MerchantID.
- */
- public function __construct( $options = array ( ) ) {
- if ( is_null( $options ) ) {
- $options = array ( );
- }
-
- //I hate myself for this part, and so do you.
- //Deliberately not fixing the actual problem for this patchset.
- //@TODO: Change the way the constructor works in all adapter
- //objects, such that the mess I am about to make is no longer
- //necessary. A patchset may already be near-ready for this...
- if ( array_key_exists( 'order_id_meta', $options ) ) {
- $this->order_id_meta = $options['order_id_meta'];
- unset( $options['order_id_meta'] );
- }
-
- $this->options = $options;
-
- parent::__construct( $this->options );
- }
-
- /**
- * Clear the static globals cache.
- */
- public static function clearGlobalsCache() {
- self::$globalsCache = array ( );
- }
-
- /**
- * Returns the variable $this->dataObj which should be an instance of
- * DonationData.
- *
- * @return DonationData
- */
- public function getDonationData() {
- return $this->dataObj;
- }
-
- public function _addCodeRange() {
- return call_user_func_array(array($this, 'addCodeRange'),
func_get_args());
- }
-
- public function _findCodeAction() {
- return call_user_func_array(array($this, 'findCodeAction'),
func_get_args());
- }
-
- public function _buildRequestXML() {
- return call_user_func_array( array ( $this, 'buildRequestXML'
), func_get_args() );
- }
-
- public function _getData_Staged() {
- return call_user_func_array( array ( $this, 'getData_Staged' ),
func_get_args() );
- }
-
- public function _stageData() {
- $this->stageData();
- }
-
- /**
- * @TODO: Get rid of this and the override mechanism as soon as you
- * refactor the constructor into something reasonable.
- * @return type
- */
- public function defineOrderIDMeta() {
- if ( isset( $this->order_id_meta ) ) {
- return;
- }
- parent::defineOrderIDMeta();
- }
-
- /**
- * Stub out the limboStomp fn and record the calls
- * @param type $antiMessage
- */
- public function doLimboStompTransaction( $antiMessage = false ) {
- $this->limbo_stomps[] = $antiMessage;
- }
- /**
- * Trap the error log so we can use it in testing
- * @param type $msg
- * @param type $log_level
- * @param type $log_id_suffix
- */
- public function log( $msg, $log_level = LOG_INFO, $log_id_suffix = ''){
- //I don't care about the suffix right now, particularly.
- $this->testlog[$log_level][] = $msg;
- }
-
- //@TODO: That minfraud jerk needs its own isolated tests.
- function runAntifraudHooks() {
- //now screw around with the batch settings to trick the fraud
filters into triggering
- $is_batch = $this->isBatchProcessor();
- $this->batch = true;
-
- parent::runAntifraudHooks();
-
- $this->batch = $is_batch;
- }
-
- public function getRiskScore() {
- return $this->risk_score;
- }
-
- /**
- * 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 );
- }
-
- /**
- * 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;
- }
-
- //could start stashing these in a further-down subdir if
payment type starts getting in the way,
- //but frankly I don't want to write tests that test our dummy
responses.
- $file_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR;
- $file_path .= 'Responses' . DIRECTORY_SEPARATOR .
self::getIdentifier() . DIRECTORY_SEPARATOR;
- $file_path .= $this->getCurrentTransaction() . $code .
'.testresponse';
-
- //these are all going to be short, so...
- if ( file_exists( $file_path ) ) {
- return file_get_contents( $file_path );
- } else {
- echo "File $file_path does not exist.\n"; //<-That will
deliberately break the test.
- return false;
- }
- }
-
- /**
- * Load in some dummy curl response info so we can test proper response
processing
- */
- protected function curl_getinfo( $ch, $opt = null ) {
- $code = 200; //response OK
- if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
- $code = ( int ) $this->dummyCurlResponseCode;
- }
-
- //put more here if it ever turns out that we care about it.
- return array (
- 'http_code' => $code,
- );
- }
-
-}
-
-
-
-/**
- * TestingPaypalAdapter
- * @TODO: Extend/damage things here. I'm sure we'll need it eventually...
- */
-class TestingPaypalAdapter extends PaypalAdapter {
- /**
- * 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;
- }
-
- //could start stashing these in a further-down subdir if
payment type starts getting in the way,
- //but frankly I don't want to write tests that test our dummy
responses.
- $file_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR;
- $file_path .= 'Responses' . DIRECTORY_SEPARATOR .
self::getIdentifier() . DIRECTORY_SEPARATOR;
- $file_path .= $this->getCurrentTransaction() . $code .
'.testresponse';
-
- //these are all going to be short, so...
- if ( file_exists( $file_path ) ) {
- return file_get_contents( $file_path );
- } else {
- echo "File $file_path does not exist.\n"; //<-That will
deliberately break the test.
- return false;
- }
- }
-
- /**
- * Load in some dummy curl response info so we can test proper response
processing
- */
- protected function curl_getinfo( $ch, $opt = null ) {
- $code = 200; //response OK
- if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
- $code = ( int ) $this->dummyCurlResponseCode;
- }
-
- //put more here if it ever turns out that we care about it.
- return array (
- 'http_code' => $code,
- );
- }
-
-}
-
-/**
- * TestingAmazonAdapter
- */
-class TestingAmazonAdapter extends AmazonAdapter {
-
- public static $fakeGlobals = array();
-
- public static function getGlobal( $name ) {
- if ( array_key_exists( $name,
TestingAmazonAdapter::$fakeGlobals ) ) {
- return TestingAmazonAdapter::$fakeGlobals[$name];
- }
- return parent::getGlobal( $name );
- }
-
- public function _buildRequestParams() {
- return $this->buildRequestParams();
- }
- /**
- * 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;
- }
-
- //could start stashing these in a further-down subdir if
payment type starts getting in the way,
- //but frankly I don't want to write tests that test our dummy
responses.
- $file_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR;
- $file_path .= 'Responses' . DIRECTORY_SEPARATOR .
self::getIdentifier() . DIRECTORY_SEPARATOR;
- $file_path .= $this->getCurrentTransaction() . $code .
'.testresponse';
-
- //these are all going to be short, so...
- if ( file_exists( $file_path ) ) {
- return file_get_contents( $file_path );
- } else {
- echo "File $file_path does not exist.\n"; //<-That will
deliberately break the test.
- return false;
- }
- }
-
- /**
- * Load in some dummy curl response info so we can test proper response
processing
- */
- protected function curl_getinfo( $ch, $opt = null ) {
- $code = 200; //response OK
- if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
- $code = ( int ) $this->dummyCurlResponseCode;
- }
-
- //put more here if it ever turns out that we care about it.
- return array (
- 'http_code' => $code,
- );
- }
-
-}
-
-/**
- * TestingAdyenAdapter
- */
-class TestingAdyenAdapter extends AdyenAdapter {
-
- public $testlog = array ( );
-
- public function _buildRequestParams() {
- return $this->buildRequestParams();
- }
-
- //@TODO: That minfraud jerk needs its own isolated tests.
- function runAntifraudHooks() {
- //now screw around with the batch settings to trick the fraud
filters into triggering
- $is_batch = $this->isBatchProcessor();
- $this->batch = true;
-
- parent::runAntifraudHooks();
-
- $this->batch = $is_batch;
- }
-
- public function _getData_Staged() {
- return call_user_func_array( array ( $this, 'getData_Staged' ),
func_get_args() );
- }
-
- /**
- * So we can fake a risk score
- */
- public function setRiskScore( $score ) {
- $this->risk_score = $score;
- }
-
- /**
- * Trap the error log so we can use it in testing
- * @param type $msg
- * @param type $log_level
- * @param type $log_id_suffix
- */
- public function log( $msg, $log_level = LOG_INFO, $log_id_suffix = '' )
{
- //I don't care about the suffix right now, particularly.
- $this->testlog[$log_level][] = $msg;
- }
-
- /**
- * 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;
- }
-
- //could start stashing these in a further-down subdir if
payment type starts getting in the way,
- //but frankly I don't want to write tests that test our dummy
responses.
- $file_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR;
- $file_path .= 'Responses' . DIRECTORY_SEPARATOR .
self::getIdentifier() . DIRECTORY_SEPARATOR;
- $file_path .= $this->getCurrentTransaction() . $code .
'.testresponse';
-
- //these are all going to be short, so...
- if ( file_exists( $file_path ) ) {
- return file_get_contents( $file_path );
- } else {
- echo "File $file_path does not exist.\n"; //<-That will
deliberately break the test.
- return false;
- }
- }
-
- /**
- * Load in some dummy curl response info so we can test proper response
processing
- */
- protected function curl_getinfo( $ch, $opt = null ) {
- $code = 200; //response OK
- if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
- $code = ( int ) $this->dummyCurlResponseCode;
- }
-
- //put more here if it ever turns out that we care about it.
- return array (
- 'http_code' => $code,
- );
- }
-
-}
-
-/**
- * TestingWorldPayAdapter
- */
-class TestingWorldPayAdapter extends WorldPayAdapter {
-
- public $testlog = array ( );
- public $curled = '';
-
- //@TODO: That minfraud jerk needs its own isolated tests.
- function runAntifraudHooks() {
- //now screw around with the batch settings to trick the fraud
filters into triggering
- $is_batch = $this->isBatchProcessor();
- $this->batch = true;
-
- parent::runAntifraudHooks();
-
- $this->batch = $is_batch;
- }
-
- /**
- * Trap the error log so we can use it in testing
- * @param type $msg
- * @param type $log_level
- * @param type $log_id_suffix
- */
- public function log( $msg, $log_level = LOG_INFO, $log_id_suffix = '' )
{
- //I don't care about the suffix right now, particularly.
- $this->testlog[$log_level][] = $msg;
- }
-
- public function getRiskScore() {
- return $this->risk_score;
- }
-
- /**
- * 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 );
- }
-
- /**
- * 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;
- }
-
- //could start stashing these in a further-down subdir if
payment type starts getting in the way,
- //but frankly I don't want to write tests that test our dummy
responses.
- $file_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR;
- $file_path .= 'Responses' . DIRECTORY_SEPARATOR .
self::getIdentifier() . DIRECTORY_SEPARATOR;
- $file_path .= $this->getCurrentTransaction() . $code .
'.testresponse';
-
- //these are all going to be short, so...
- if ( file_exists( $file_path ) ) {
- return file_get_contents( $file_path );
- } else {
- echo "File $file_path does not exist.\n"; //<-That will
deliberately break the test.
- return false;
- }
- }
-
- /**
- * Load in some dummy curl response info so we can test proper response
processing
- */
- protected function curl_getinfo( $ch, $opt = null ) {
- $code = 200; //response OK
- if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
- $code = ( int ) $this->dummyCurlResponseCode;
- }
-
- //put more here if it ever turns out that we care about it.
- return array (
- 'http_code' => $code,
- );
- }
-
- public function _stageData() {
- $this->stageData();
- }
-
- public function _getData_Staged( $val = '' ) {
- return $this->getData_Staged( $val );
- }
-}
-
-/**
- * TestingGlobalCollectOrphanAdapter
- *
- * This is officially truly silly now.
- * TODO: Poke own eye out before you notice that multiple inheritance would, if
- * available, cause this file to deflate by 4/5ths.
- */
-
-class TestingGlobalCollectOrphanAdapter extends GlobalCollectOrphanAdapter {
-
- public $testlog = array ( );
-
- public $curled = array ( );
-
- /**
- * Also set a useful MerchantID.
- */
- public function __construct( $options = array ( ) ) {
- if ( is_null( $options ) ) {
- $options = array ( );
- }
-
- //I hate myself for this part, and so do you.
- //Deliberately not fixing the actual problem for this patchset.
- //@TODO: Change the way the constructor works in all adapter
- //objects, such that the mess I am about to make is no longer
- //necessary. A patchset may already be near-ready for this...
- if ( array_key_exists( 'order_id_meta', $options ) ) {
- $this->order_id_meta = $options['order_id_meta'];
- unset( $options['order_id_meta'] );
- }
-
- $this->options = $options;
-
- parent::__construct( $this->options );
- }
-
- /**
- * Returns the variable $this->dataObj which should be an instance of
- * DonationData.
- *
- * @return DonationData
- */
- public function getDonationData() {
- return $this->dataObj;
- }
-
- public function _addCodeRange() {
- return call_user_func_array( array ( $this, 'addCodeRange' ),
func_get_args() );
- }
-
- public function _findCodeAction() {
- return call_user_func_array( array ( $this, 'findCodeAction' ),
func_get_args() );
- }
-
- public function _buildRequestXML() {
- return call_user_func_array( array ( $this, 'buildRequestXML'
), func_get_args() );
- }
-
- public function _getData_Staged() {
- return call_user_func_array( array ( $this, 'getData_Staged' ),
func_get_args() );
- }
-
- public function _stageData() {
- $this->stageData();
- }
-
- /**
- * @TODO: Get rid of this and the override mechanism as soon as you
- * refactor the constructor into something reasonable.
- * @return type
- */
- public function defineOrderIDMeta() {
- if ( isset( $this->order_id_meta ) ) {
- return;
- }
- parent::defineOrderIDMeta();
- }
-
- /**
- * Trap the error log so we can use it in testing
- * @param type $msg
- * @param type $log_level
- * @param type $log_id_suffix
- */
- public function log( $msg, $log_level = LOG_INFO, $log_id_suffix = '' )
{
- //I don't care about the suffix right now, particularly.
- $this->testlog[$log_level][] = $msg;
- }
-
- //@TODO: That minfraud jerk needs its own isolated tests.
- function runAntifraudHooks() {
- //now screw around with the batch settings to trick the fraud
filters into triggering
- $is_batch = $this->isBatchProcessor();
- $this->batch = true;
-
- parent::runAntifraudHooks();
-
- $this->batch = $is_batch;
- }
-
- public function getRiskScore() {
- return $this->risk_score;
- }
-
- /**
- * 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 );
- }
-
- /**
- * 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;
- }
-
- //could start stashing these in a further-down subdir if
payment type starts getting in the way,
- //but frankly I don't want to write tests that test our dummy
responses.
- $file_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR;
- $file_path .= 'Responses' . DIRECTORY_SEPARATOR .
self::getIdentifier() . DIRECTORY_SEPARATOR;
- $file_path .= $this->getCurrentTransaction() . $code .
'.testresponse';
-
- //these are all going to be short, so...
- if ( file_exists( $file_path ) ) {
- return file_get_contents( $file_path );
- } else {
- echo "File $file_path does not exist.\n"; //<-That will
deliberately break the test.
- return false;
- }
- }
-
- /**
- * Load in some dummy curl response info so we can test proper response
processing
- */
- protected function curl_getinfo( $ch, $opt = null ) {
- $code = 200; //response OK
- if ( property_exists( $this, 'dummyCurlResponseCode' ) ) {
- $code = ( int ) $this->dummyCurlResponseCode;
- }
-
- //put more here if it ever turns out that we care about it.
- return array (
- 'http_code' => $code,
- );
- }
-
-}
-
->>>>>>> BRANCH (5e90d5 Add IP spanking for shady cards to Worldpay)
--
To view, visit https://gerrit.wikimedia.org/r/167045
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic85670419e0bab6d4eb1d6c148fbf83eb00d24a5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: deploy-payments_1.22
Gerrit-Owner: Katie Horn <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits