Katie Horn has submitted this change and it was merged.
Change subject: Merge branch 'master' into deploy
......................................................................
Merge branch 'master' into deploy
Conflicts:
tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
tests/Adapter/WorldPay/WorldPayTest.php
Change-Id: I044f7ad5303914119e5dbe790b9420a4365af082
---
D tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
D tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
D tests/Adapter/WorldPay/WorldPayTest.php
3 files changed, 0 insertions(+), 812 deletions(-)
Approvals:
Katie Horn: Looks good to me, approved
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
b/tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
deleted file mode 100644
index b74f77c..0000000
--- a/tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
+++ /dev/null
@@ -1,251 +0,0 @@
-<<<<<<< HEAD (51e7f7 Localisation updates from https://translatewiki.net.)
-=======
-<?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 GlobalCollectFormLoadTest extends DonationInterfaceTestCase {
-
- 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',
- ),
- 'country' => array (
- 'nodename' => 'select',
- 'selected' => 'FR',
- ),
- );
-
- $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init,
$assertNodes, true );
- }
-
- /**
- * Ensure that form loads for Italy
- */
- public function testGlobalCollectFormLoad_IT() {
- $init = $this->getDonorTestData( 'IT' );
- 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',
- 'placeholder' => wfMessage(
'donate_interface-donor-fname')->inLanguage( 'it' )->text(),
- ),
- 'lname' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-lname')->inLanguage( 'it' )->text(),
- ),
- 'informationsharing' => array (
- 'nodename' => 'p',
- 'innerhtml' => wfMessage(
'donate_interface-informationsharing', '.*' )->inLanguage( 'it' )->text(),
- ),
- 'country' => array (
- 'nodename' => 'select',
- 'selected' => 'IT',
- ),
- );
-
- $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init,
$assertNodes, true );
- }
-
- /**
- * Make sure Belgian form loads in all of that country's supported
languages
- * @dataProvider belgiumLanguageProvider
- */
- public function testGlobalCollectFormLoad_BE( $language ) {
- $init = $this->getDonorTestData( 'BE' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'cc-vmaj';
- $init['language'] = $language;
-
- $assertNodes = array (
- 'selected-amount' => array (
- 'nodename' => 'span',
- 'innerhtml' => '€1.55',
- ),
- 'fname' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-fname')->inLanguage( $language )->text(),
- ),
- 'lname' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-lname')->inLanguage( $language )->text(),
- ),
- 'informationsharing' => array (
- 'nodename' => 'p',
- 'innerhtml' => wfMessage(
'donate_interface-informationsharing', '.*' )->inLanguage( $language )->text(),
- ),
- 'country' => array (
- 'nodename' => 'select',
- 'selected' => 'BE',
- ),
- );
-
- $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init,
$assertNodes, true );
- }
-
- /**
- * Make sure Belgian form loads in all of that country's supported
languages
- * @dataProvider belgiumLanguageProvider
- */
- public function testGlobalCollectSofortLoad_BE( $language ) {
- $init = $this->getDonorTestData( 'BE' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'rtbt';
- $init['payment_submethod'] = 'rtbt_sofortuberweisung';
- $init['ffname'] = 'rtbt-sofo';
- $init['language'] = $language;
-
- $assertNodes = array (
- 'fname' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-fname')->inLanguage( $language )->text(),
- ),
- 'lname' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-lname')->inLanguage( $language )->text(),
- ),
- 'emailAdd' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-email')->inLanguage( $language )->text(),
- ),
- 'informationsharing' => array (
- 'nodename' => 'p',
- 'innerhtml' => wfMessage(
'donate_interface-informationsharing', '.*' )->inLanguage( $language )->text(),
- ),
- 'country' => array (
- 'nodename' => 'select',
- 'selected' => 'BE',
- ),
- );
-
- $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init,
$assertNodes, true );
- }
-
- /**
- * Supported languages for Belgium
- */
- public function belgiumLanguageProvider() {
- return array(
- array( 'nl' ),
- array( 'de' ),
- array( 'fr' ),
- );
- }
-
- /**
- * Make sure Canadian CC form loads in English and French
- * @dataProvider canadaLanguageProvider
- */
- public function testGlobalCollectFormLoad_CA( $language ) {
- $init = $this->getDonorTestData( 'CA' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'cc-vma';
- $init['language'] = $language;
-
- $assertNodes = array (
- 'selected-amount' => array (
- 'nodename' => 'span',
- 'innerhtml' => '1.55 CAD',
- ),
- 'fname' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-fname')->inLanguage( $language )->text(),
- ),
- 'lname' => array (
- 'nodename' => 'input',
- 'placeholder' => wfMessage(
'donate_interface-donor-lname')->inLanguage( $language )->text(),
- ),
- 'informationsharing' => array (
- 'nodename' => 'p',
- 'innerhtml' => wfMessage(
'donate_interface-informationsharing', '.*' )->inLanguage( $language )->text(),
- ),
- 'state' => array (
- 'nodename' => 'select',
- 'selected' => 'SK',
- ),
- 'zip' => array (
- 'nodename' => 'input',
- 'value' => $init['zip'],
- ),
- 'country' => array (
- 'nodename' => 'input',
- 'value' => 'CA',
- ),
- );
-
- $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init,
$assertNodes, true );
- }
-}
->>>>>>> BRANCH (7ac4fd typo-O)
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
b/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
deleted file mode 100644
index de19bf9..0000000
--- a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
+++ /dev/null
@@ -1,151 +0,0 @@
-<<<<<<< HEAD (51e7f7 Localisation updates from https://translatewiki.net.)
-=======
-<?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_GlobalCollectTest
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 );
- }
-
- /**
- * 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 (7ac4fd typo-O)
diff --git a/tests/Adapter/WorldPay/WorldPayTest.php
b/tests/Adapter/WorldPay/WorldPayTest.php
deleted file mode 100644
index 51628be..0000000
--- a/tests/Adapter/WorldPay/WorldPayTest.php
+++ /dev/null
@@ -1,410 +0,0 @@
-<<<<<<< HEAD (51e7f7 Localisation updates from https://translatewiki.net.)
-=======
-<?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 WorldPay
- */
-class DonationInterface_Adapter_WorldPay_WorldPayTest 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 = 'TestingWorldPayAdapter';
- }
-
- /**
- * Just making sure we can instantiate the thing without blowing up
completely
- */
- function testConstruct() {
- $options = $this->getDonorTestData();
- $class = $this->testAdapterClass;
-
- $_SERVER['REQUEST_URI'] =
GatewayFormChooser::buildPaymentsFormURL( 'testytest', array ( 'gateway' =>
$class::getIdentifier() ) );
- $gateway = $this->getFreshGatewayObject( $options );
-
- $this->assertInstanceOf( 'TestingWorldPayAdapter', $gateway );
- }
-
- /**
- * Test the AntiFraud hooks
- */
- function testAntiFraudHooks() {
- $options = $this->getDonorTestData( 'US' );
- $options['utm_source'] = "somethingmedia";
- $options['email'] = "[email protected]";
-
- $gateway = $this->getFreshGatewayObject( $options );
-
- $gateway->runAntifraudHooks();
-
- $this->assertEquals( 'reject', $gateway->getValidationAction(),
'Validation action is not as expected' );
- $this->assertEquals( 113, $gateway->getRiskScore(), 'RiskScore
is not as expected' );
- }
-
- /**
- * Just making sure we can instantiate the thing without blowing up
completely
- */
- function testNeverLog() {
- $options = $this->getDonorTestData();
- $options['cvv'] = '123';
- $class = $this->testAdapterClass;
-
- $_SERVER['REQUEST_URI'] =
GatewayFormChooser::buildPaymentsFormURL( 'testytest', array ( 'gateway' =>
$class::getIdentifier() ) );
- $gateway = $this->getFreshGatewayObject( $options );
-
- $this->assertInstanceOf( 'TestingWorldPayAdapter', $gateway );
- $gateway->do_transaction( 'AuthorizePaymentForFraud' );
-
- $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO,
'/Request XML/' );
-
- $this->assertType( 'string', $logline, "We did not receive
exactly one logline back that contains request XML" );
- $this->assertEquals( '1', preg_match( '/Cleaned/', $logline ),
'The logline did not come back marked as "Cleaned".' );
- $this->assertEquals( '0', preg_match( '/CNV/', $logline ), 'The
"Cleaned" logline contained CVN data!' );
- }
-
- function testWorldPayFormLoad() {
- $init = $this->getDonorTestData();
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'worldpay';
- $init['currency_code'] = 'EUR';
-
- $assertNodes = array (
- 'selected-amount' => array (
- 'nodename' => 'span',
- 'innerhtml' => '€1.55',
- ),
- 'fname' => array(
- 'nodename' => 'input',
- 'value' => 'Firstname',
- ),
- 'lname' => array(
- 'nodename' => 'input',
- 'value' => 'Surname',
- ),
- 'street' => array(
- 'nodename' => 'input',
- 'value' => '123 Fake Street',
- ),
- 'city' => array(
- 'nodename' => 'input',
- 'value' => 'San Francisco',
- ),
- 'zip' => array(
- 'nodename' => 'input',
- 'value' => '94105',
- ),
- 'country' => array(
- 'nodename' => 'input',
- 'value' => 'US',
- ),
- 'emailAdd' => array(
- 'nodename' => 'input',
- 'value' => '',
- ),
- 'language' => array(
- 'nodename' => 'input',
- 'value' => 'en',
- ),
- 'state' => array(
- 'nodename' => 'select',
- 'selected' => 'CA',
- ),
- 'informationsharing' => array (
- 'nodename' => 'p',
- 'innerhtml' => "By donating, you agree to share
your personal information with the Wikimedia Foundation, the nonprofit
organization that hosts Wikipedia and other Wikimedia projects, and its service
providers pursuant to our <a
href=\"//wikimediafoundation.org/wiki/Donor_policy\">donor policy</a>.
Wikimedia Foundation and its service providers are located in the United States
and in other countries whose privacy laws may not be equivalent to your own. We
do not sell or trade your information to anyone. For more information please
read our <a href=\"//wikimediafoundation.org/wiki/Donor_policy\">donor
policy</a>."
- ),
- );
-
- $this->verifyFormOutput( 'TestingWorldPayGateway', $init,
$assertNodes, true );
- }
-
- function testPaymentFormSubmit() {
- $init = $this->getDonorTestData( 'FR' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'worldpay';
- $init['currency_code'] = 'EUR';
- $init['email'] = '[email protected]';
-
- $init['OTT'] = 'SALT123456789';
-
- $assertNodes = array(
- 'headers' => array(
- 'Location' =>
'https://wikimediafoundation.org/wiki/Thank_You/fr',
- ),
- );
-
- $this->verifyFormOutput( 'TestingWorldPayGateway', $init,
$assertNodes, true );
- }
-
- function testWorldPayFormLoad_FR() {
- $init = $this->getDonorTestData( 'FR' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'worldpay';
-
- $assertNodes = array (
- 'selected-amount' => array (
- 'nodename' => 'span',
- 'innerhtml' => '€1.55',
- ),
- 'fname' => array (
- 'nodename' => 'input',
- 'value' => 'Prénom',
- ),
- 'lname' => array (
- 'nodename' => 'input',
- 'value' => 'Nom',
- ),
- 'country' => array (
- 'nodename' => 'input',
- 'value' => 'FR',
- ),
- );
-
- $this->verifyFormOutput( 'TestingWorldPayGateway', $init,
$assertNodes, true );
- }
-
- /**
- * Make sure Belgian form loads in all of that country's supported
languages
- * @dataProvider belgiumLanguageProvider
- */
- public function testWorldPayFormLoad_BE( $language ) {
- $init = $this->getDonorTestData( 'BE' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'cc';
- $init['payment_submethod'] = 'visa';
- $init['ffname'] = 'worldpay';
- $init['language'] = $language;
-
- $assertNodes = array (
- 'selected-amount' => array (
- 'nodename' => 'span',
- 'innerhtml' => '€1.55',
- ),
- 'fname-label' => array (
- 'nodename' => 'label',
- 'innerhtml' => wfMessage(
'donate_interface-donor-fname' )->inLanguage( $language )->text(),
- ),
- 'lname-label' => array (
- 'nodename' => 'label',
- 'innerhtml' => wfMessage(
'donate_interface-donor-lname' )->inLanguage( $language )->text(),
- ),
- 'emailAdd-label' => array (
- 'nodename' => 'label',
- 'innerhtml' => wfMessage(
'donate_interface-donor-email' )->inLanguage( $language )->text(),
- ),
- 'informationsharing' => array (
- 'nodename' => 'p',
- 'innerhtml' => wfMessage(
'donate_interface-informationsharing', '.*' )->inLanguage( $language )->text(),
- ),
- );
-
- $this->verifyFormOutput( 'TestingWorldPayGateway', $init,
$assertNodes, true );
- }
-
- /**
- * Testing that we can retrieve the cvv_match value and run antifraud
on it correctly
- */
- function testAntifraudCVVMatch() {
- $options = $this->getDonorTestData(); //don't really care:
We'll be using the dummy response directly.
- $class = $this->testAdapterClass;
-
- $gateway = $this->getFreshGatewayObject( $options );
- $gateway->do_transaction( 'AuthorizePaymentForFraud' );
-
- $this->assertEquals( '1', $gateway->getData_Unstaged_Escaped(
'cvv_result' ), 'cvv_result was not set after AuthorizePaymentForFraud' );
- $this->assertTrue( $gateway->getCVVResult(), 'getCVVResult not
passing somebody with a match.' );
-
- //and now, for fun, test a wrong code.
- $gateway->addData( array ( 'cvv_result' => '2' ), 'response' );
- $this->assertFalse( $gateway->getCVVResult(), 'getCVVResult not
failing somebody with garbage.' );
- }
-
- /**
- * Ensure we don't give too high a risk score when AVS address / zip
match was not performed
- */
- function testAntifraudAllowsAvsNotPerformed() {
- $options = $this->getDonorTestData('FR'); //don't really care:
We'll be using the dummy response directly.
-
- $gateway = $this->getFreshGatewayObject( $options );
- $gateway->setDummyGatewayResponseCode( 9000 );
- $gateway->do_transaction( 'AuthorizePaymentForFraud' );
-
- $this->assertEquals( '9', $gateway->getData_Unstaged_Escaped(
'avs_address' ), 'avs_address was not set after AuthorizePaymentForFraud' );
- $this->assertEquals( '9', $gateway->getData_Unstaged_Escaped(
'avs_zip' ), 'avs_zip was not set after AuthorizePaymentForFraud' );
- $this->assertTrue( $gateway->getAVSResult() < 25, 'getAVSResult
returning too high a score for AVS not performed.' );
- }
-
- /**
- * Check to make sure we don't run antifraud filters (and burn a
minfraud query) when we know the transaction has already failed
- */
- function testAntifraudNotPerformedOnGatewayError() {
- $options = $this->getDonorTestData( 'FR' ); //don't really
care: We'll be using the dummy response directly.
-
- $gateway = $this->getFreshGatewayObject( $options );
- $gateway->setDummyGatewayResponseCode( 2208 ); //account
problems
- $gateway->do_transaction( 'AuthorizePaymentForFraud' );
-
- //assert that:
- //#1 - the gateway object has an appropriate transaction error
set
- //#2 - antifraud checks were not performed.
-
- //check for the error code that corresponds to the transaction
coming back with a failure, rather than the one that we use for fraud fail.
- $errors = $gateway->getTransactionErrors();
- $this->assertTrue( !empty( $errors ), 'No errors in
getTransactionErrors after a bad "AuthorizePaymentForFraud"' );
- $this->assertTrue( array_key_exists( 'internal-0001', $errors
), 'Unexpected error code' );
-
- //check more things to make sure we didn't run any fraud filters
- $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO,
'/Preparing to run custom filters/' );
- $this->assertFalse( $logline, 'According to the logs, we ran
antifraud filters and should not have' );
- $this->assertEquals( 'process',
$gateway->getValidationAction(), 'Validation action is not as expected' );
- $this->assertEquals( 0, $gateway->getRiskScore(), 'RiskScore is
not as expected' );
-
- }
-
- /**
- * Check to make sure we do run antifraud filters when we know the
transaction is okay to go
- */
- function testAntifraudPerformedOnGatewayNoError() {
- $options = $this->getDonorTestData( 'FR' ); //don't really
care: We'll be using the dummy response directly.
- $options['email'] = '[email protected]';
-
- $gateway = $this->getFreshGatewayObject( $options );
-// $gateway->setDummyGatewayResponseCode( 2208 ); //account
problems
- $gateway->do_transaction( 'AuthorizePaymentForFraud' );
-
- //assert that:
- //#1 - the gateway object has no errors set
- //#2 - antifraud checks were performed.
- $errors = $gateway->getTransactionErrors();
- $this->assertTrue( empty( $errors ), 'Errors assigned in
getTransactionErrors after a good "AuthorizePaymentForFraud"' );
- //check more things to make sure we did run the fraud filters
- $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO,
'/CustomFiltersScores/' );
- $this->assertType( 'string', $logline, 'No antifraud filters
were run, according to the logs' );
- $this->assertEquals( 'process',
$gateway->getValidationAction(), 'Validation action is not as expected' );
- $this->assertEquals( 0, $gateway->getRiskScore(), 'RiskScore is
not as expected' );
- }
-
- /**
- * Ensure we're staging a punctuation-stripped version of the email
address in merchant_reference_2
- */
- function testMerchantReference2() {
- $options = $this->getDonorTestData();
- $options['email'] = '[email protected]';
- $gateway = $this->getFreshGatewayObject( $options );
- $gateway->_stageData();
- $staged = $gateway->_getData_Staged( 'merchant_reference_2' );
- $this->assertEquals( 'little teapot short stout com', $staged );
- }
-
- function testTransliterateUtf8forEurocentricProcessor() {
- $options = $this->getDonorTestData();
- $options['fname'] = 'Barnabáš';
- $options['lname'] = 'Voříšek';
- $options['street'] = 'Truhlářská 320/62';
- $options['city'] = 'České Budějovice';
- $class = $this->testAdapterClass;
-
- $_SERVER['REQUEST_URI'] =
GatewayFormChooser::buildPaymentsFormURL( 'testytest', array ( 'gateway' =>
$class::getIdentifier() ) );
- $gateway = $this->getFreshGatewayObject( $options );
-
- $gateway->_stageData();
- $gateway->do_transaction( 'AuthorizeAndDepositPayment' );
- $xml = new SimpleXMLElement( preg_replace( '/StringIn=/', '',
$gateway->curled ) );
- $this->assertEquals( 'Barnabás', $xml->FirstName );
- $this->assertEquals( 'Vorísek', $xml->LastName );
- $this->assertEquals( 'Truhlárská 320/62', $xml->Address1 );
- $this->assertEquals( 'Ceské Budejovice', $xml->City );
- }
-
- /**
- * Check that whacky #.# format orderid is unmolested by order_id_meta
validation.
- */
- function testWackyOrderIdPassedValidation() {
- $init = $this->initial_vars;
-
- $init['order_id'] = '2143.0';
- unset( $_POST['order_id'] );
- unset( $_SESSION['Donor']['order_id'] );
- $gateway = $this->getFreshGatewayObject( $init, array( 'batch_mode' =>
TRUE, ) );
- $this->assertEquals( $init['order_id'],
$gateway->getData_Unstaged_Escaped( 'order_id' ),
- 'Decimal Order ID is allowed by orderIdMeta validation'
);
- }
-
- /**
- * Check that order_id is built from contribution_tracking id.
- */
- function testWackyOrderIdBasedOnContributionTracking() {
- $init = $this->initial_vars;
-
- $init['contribution_tracking_id'] = mt_rand();
- $_SESSION['numAttempt'] = 2;
- unset( $_POST['order_id'] );
- $gateway = $this->getFreshGatewayObject( $init, array( 'batch_mode' =>
TRUE, ) );
- $expected_order_id =
"{$init['contribution_tracking_id']}.{$_SESSION['numAttempt']}";
- $this->assertEquals( $expected_order_id,
$gateway->getData_Unstaged_Escaped( 'order_id' ),
- 'Decimal Order ID is correctly built from Contribution
Tracking ID.' );
- }
-
- /**
- * Ensure processResponse doesn't fail trxn for special accounts when
AVS
- * nodes are missing.
- */
- function testProcessResponseAllowsSnowflakeAVSMissing() {
- $options = $this->getDonorTestData( 'FJ' ); // 'FJ' store ID is
set up as a special exception
-
- $gateway = $this->getFreshGatewayObject( $options );
- $gateway->setDummyGatewayResponseCode( 'snowflake' );
- $results = $gateway->do_transaction( 'AuthorizePaymentForFraud'
);
-
- // internal-0001 is the error code processRespose adds for
missing nodes
- $this->assertFalse( array_key_exists( 'internal-0001',
$results['errors'] ),
- 'processResponse is failing a special snowflake account
with a response missing AVS nodes' );
- }
-
- /**
- * Ensure we don't give too high a risk score for special accounts when
- * AVS address / zip match was not performed and CVV reports failure
- */
- function testAntifraudAllowsSnowflakeAVSMissingAndCVVMismatch() {
- $options = $this->getDonorTestData( 'FJ' ); // 'FJ' store ID is
set up as a special exception
-
- $gateway = $this->getFreshGatewayObject( $options );
- $gateway->setDummyGatewayResponseCode( 'snowflake' );
- $gateway->do_transaction( 'AuthorizePaymentForFraud' );
-
- $this->assertTrue( $gateway->getCVVResult(), 'getCVVResult
failing snowflake account' );
-
- $this->assertTrue( $gateway->getAVSResult() < 25, 'getAVSResult
giving snowflake account too high a risk score' );
- }
-}
->>>>>>> BRANCH (7ac4fd typo-O)
--
To view, visit https://gerrit.wikimedia.org/r/175612
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I044f7ad5303914119e5dbe790b9420a4365af082
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: deployment
Gerrit-Owner: Katie Horn <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits