Awight has uploaded a new change for review.
https://gerrit.wikimedia.org/r/206179
Change subject: Merge master into deployment
......................................................................
Merge master into deployment
Change-Id: I12557822293e79b37da1bafce344dcb5c32b5138
---
M DonationInterface.php
D tests/Adapter/Astropay/AstropayTest.php
D tests/DonationQueueTest.php
D tests/includes/Responses/astropay/PaymentStatus.testresponse
D tests/includes/Responses/astropay/PaymentStatus_badsig.testresponse
D tests/includes/TestingQueue.php
6 files changed, 0 insertions(+), 547 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/79/206179/1
diff --git a/DonationInterface.php b/DonationInterface.php
index 4e50a16..3838e47 100644
--- a/DonationInterface.php
+++ b/DonationInterface.php
@@ -1127,38 +1127,6 @@
if ($optionalParts['Stomp'] === true){
require_once( $donationinterface_dir .
'activemq_stomp/activemq_stomp.php' );
$wgAutoloadClasses['Stomp'] = $donationinterface_dir .
'activemq_stomp/Stomp.php';
-<<<<<<< HEAD (62553c Merge master into deployment)
-=======
-}
-
-function efDonationInterfaceUnitTests( &$files ) {
- global $wgAutoloadClasses;
-
- $testDir = __DIR__ . '/tests/';
-
- $files[] = $testDir . 'AllTests.php';
-
- $wgAutoloadClasses['DonationInterfaceTestCase'] = $testDir .
'DonationInterfaceTestCase.php';
- $wgAutoloadClasses['TestingQueue'] = $testDir .
'includes/TestingQueue.php';
- $wgAutoloadClasses['TestingAdyenAdapter'] = $testDir .
'includes/test_gateway/TestingAdyenAdapter.php';
- $wgAutoloadClasses['TestingAmazonAdapter'] = $testDir .
'includes/test_gateway/TestingAmazonAdapter.php';
- $wgAutoloadClasses['TestingAstropayAdapter'] = $testDir .
'includes/test_gateway/TestingAstropayAdapter.php';
- $wgAutoloadClasses['TestingAmazonGateway'] = $testDir .
'includes/test_page/TestingAmazonGateway.php';
- $wgAutoloadClasses['TestingDonationLogger'] = $testDir .
'includes/TestingDonationLogger.php';
- $wgAutoloadClasses['TestingGatewayPage'] = $testDir .
'includes/TestingGatewayPage.php';
- $wgAutoloadClasses['TestingGenericAdapter'] = $testDir .
'includes/test_gateway/TestingGenericAdapter.php';
- $wgAutoloadClasses['TestingGlobalCollectAdapter'] = $testDir .
'includes/test_gateway/TestingGlobalCollectAdapter.php';
- $wgAutoloadClasses['TestingGlobalCollectGateway'] = $testDir .
'includes/test_page/TestingGlobalCollectGateway.php';
- $wgAutoloadClasses['TestingGlobalCollectOrphanAdapter'] = $testDir .
'includes/test_gateway/TestingGlobalCollectOrphanAdapter.php';
- $wgAutoloadClasses['TestingPaypalAdapter'] = $testDir .
'includes/test_gateway/TestingPaypalAdapter.php';
- $wgAutoloadClasses['TestingWorldPayAdapter'] = $testDir .
'includes/test_gateway/TestingWorldPayAdapter.php';
- $wgAutoloadClasses['TestingWorldPayGateway'] = $testDir .
'includes/test_page/TestingWorldPayGateway.php';
-
- $wgAutoloadClasses['TestingLanguage'] = $testDir .
'includes/test_language/test.language.php';
- $wgAutoloadClasses['TestingRequest'] = $testDir .
'includes/test_request/test.request.php';
-
- return true;
->>>>>>> BRANCH (539a01 Astropay result switcher)
}
unset( $optionalParts );
diff --git a/tests/Adapter/Astropay/AstropayTest.php
b/tests/Adapter/Astropay/AstropayTest.php
deleted file mode 100644
index 6bac982..0000000
--- a/tests/Adapter/Astropay/AstropayTest.php
+++ /dev/null
@@ -1,257 +0,0 @@
-<<<<<<< HEAD (62553c Merge master into deployment)
-=======
-<?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.
- *
- */
-use \Psr\Log\LogLevel;
-
-/**
- *
- * @group Fundraising
- * @group DonationInterface
- * @group Astropay
- */
-class DonationInterface_Adapter_Astropay_AstropayTest 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 = 'TestingAstropayAdapter';
- }
-
- function tearDown() {
- TestingAstropayAdapter::clearGlobalsCache();
- parent::tearDown();
- }
-
- /**
- * Ensure we're setting the right url for each transaction
- * @covers AstropayAdapter::getCurlBaseOpts
- */
- function testCurlUrl() {
- $init = $this->getDonorTestData( 'BR' );
- $gateway = $this->getFreshGatewayObject( $init );
- $gateway->setCurrentTransaction( 'NewInvoice' );
-
- $result = $gateway->getCurlBaseOpts();
-
- $this->assertEquals(
-
'https://sandbox.astropay.example.com/api_curl/streamline/NewInvoice',
- $result[CURLOPT_URL],
- 'Not setting URL to transaction-specific value.'
- );
- }
-
- /**
- * Test the NewInvoice transaction is making a sane request and signing
- * it correctly
- */
- function testNewInvoiceRequest() {
- $init = $this->getDonorTestData( 'BR' );
- $this->setLanguage( $init['language'] );
- $_SESSION['Donor']['order_id'] = '123456789';
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->do_transaction( 'NewInvoice' );
- parse_str( $gateway->curled[0], $actual );
-
- $expected = array(
- 'x_login' => 'createlogin',
- 'x_trans_key' => 'createpass',
- 'x_invoice' => '123456789',
- 'x_amount' => '100.00',
- 'x_currency' => 'BRL',
- 'x_bank' => 'TE',
- 'x_country' => 'BR',
- 'x_description' => wfMessage(
'donate_interface-donation-description' )->inLanguage( $init['language']
)->text(),
- 'x_iduser' => '08feb2d12771bbcfeb86',
- 'x_cpf' => '00003456789',
- 'x_name' => 'Nome Apelido',
- 'x_email' => '[email protected]',
- // 'x_address' => 'Rua Falso 123',
- // 'x_zip' => '01110-111',
- // 'x_city' => 'São Paulo',
- // 'x_state' => 'SP',
- 'control' =>
'AF895D1D5514842A0BC424FBC8EF9CB89E3DFBC6A4A1BA5BBC664020D6A0A476',
- 'type' => 'json',
- );
- $this->assertEquals( $expected, $actual, 'NewInvoice is not
including the right parameters' );
- }
-
- /**
- * When Astropay sends back valid JSON with status "0", we should set
txn
- * status to true and errors should be empty.
- */
- function testStatusNoErrors() {
- $init = $this->getDonorTestData( 'BR' );
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->do_transaction( 'NewInvoice' );
-
- $this->assertEquals( true, $gateway->getTransactionStatus(),
- 'Transaction status should be true for code "0"' );
-
- $this->assertEmpty( $gateway->getTransactionErrors(),
- 'Transaction errors should be empty for code "0"' );
- }
-
- /**
- * When Astropay sends back valid JSON with status "1", we should set
txn
- * status to false and error array to generic error and log a warning.
- */
- function testStatusErrors() {
- $init = $this->getDonorTestData( 'BR' );
- $this->setLanguage( $init['language'] );
- $gateway = $this->getFreshGatewayObject( $init );
- $gateway->setDummyGatewayResponseCode( '1' );
-
- $gateway->do_transaction( 'NewInvoice' );
-
- $this->assertEquals( false, $gateway->getTransactionStatus(),
- 'Transaction status should be false for code "1"' );
-
- $expected = array(
- 'internal-0000' => wfMessage(
'donate_interface-processing-error')->inLanguage( $init['language'] )->text()
- );
- $this->assertEquals( $expected,
$gateway->getTransactionErrors(),
- 'Wrong error for code "1"' );
- $logged = $this->getLogMatches( LogLevel::WARNING, '/This error
message should appear in the log.$/' );
- $this->assertNotEmpty( $logged );
- }
-
- /**
- * do_transaction should set redirect key when we get a valid response.
- */
- function testRedirectOnSuccess() {
- $init = $this->getDonorTestData( 'BR' );
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->do_transaction( 'NewInvoice' );
-
- // from the test response
- $expected =
'https://sandbox.astropaycard.com/go_to_bank?id=A5jvKfK1iHIRUTPXXt8lDFGaRRLzPgBg';
- $results = $gateway->getTransactionAllResults();
- $this->assertEquals( $expected, $results['redirect'],
- 'do_transaction is not setting the right redirect' );
- }
-
- /**
- * PaymentStatus transaction should interpret the delimited response
- */
- function testPaymentStatus() {
- $init = $this->getDonorTestData( 'BR' );
- $_SESSION['Donor']['order_id'] = '123456789';
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->do_transaction( 'PaymentStatus' );
-
- // from the test response
- $expected = array(
- 'result' => '9',
- 'x_amount' => '100.00',
- 'x_iduser' => '08feb2d12771bbcfeb86',
- 'x_invoice' => '123456789',
- 'PT' => '1',
- 'x_control' =>
'0656B92DF44B814D48D84FED2F444CCA1E991A24A365FBEECCCA15B73CC08C2A',
- 'x_document' => '987654321',
- 'x_bank' => 'TE',
- 'x_payment_type' => '03',
- 'x_bank_name' => 'GNB',
- 'x_currency' => 'BRL',
- );
- $results = $gateway->getTransactionData();
- $this->assertEquals( $expected, $results,
- 'PaymentStatus response not interpreted correctly' );
- $valid = $gateway->verifyStatusSignature( $results );
- $this->assertTrue( $valid, 'Signature should be interpreted as
valid' );
- }
-
- /**
- * Invalid signature should be recognized as such.
- */
- function testInvalidSignature() {
- $init = $this->getDonorTestData( 'BR' );
- $_SESSION['Donor']['order_id'] = '123456789';
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->setDummyGatewayResponseCode( 'badsig' );
- $gateway->do_transaction( 'PaymentStatus' );
-
- $results = $gateway->getTransactionData();
- $valid = $gateway->verifyStatusSignature( $results );
- $this->assertFalse( $valid, 'Signature should not be
interpreted as valid' );
- }
-
- /**
- * If status is paid and signature is correct, processResponse should
return
- * null and final status should be 'completed'
- */
- function testSuccessfulReturn() {
- $init = $this->getDonorTestData( 'BR' );
- $_SESSION['Donor']['order_id'] = '123456789';
- $gateway = $this->getFreshGatewayObject( $init );
-
- // Next lines mimic Astropay resultswitcher
- $gateway->setCurrentTransaction( 'ProcessReturn' );
- $gateway->addResponseData( array(
- 'result' => '9',
- 'x_amount' => '100.00',
- 'x_amount_usd' => '42.05',
- 'x_control' =>
'DDF89085AC70C0B0628150C51D64419D8592769F2439E3936570E26D24881730',
- 'x_description' => 'Donation to the Wikimedia
Foundation',
- 'x_document' => '32869',
- 'x_iduser' => '08feb2d12771bbcfeb86',
- 'x_invoice' => '123456789',
- ) );
-
- $result = $gateway->processResponse( null );
- $status = $gateway->getFinalStatus();
- $this->assertNull( $result );
- $this->assertEquals( 'complete', $status );
- }
-
- /**
- * If payment is rejected, final status should be 'failed'
- */
- function testRejectedReturn() {
- $init = $this->getDonorTestData( 'BR' );
- $_SESSION['Donor']['order_id'] = '123456789';
- $gateway = $this->getFreshGatewayObject( $init );
-
- $gateway->setCurrentTransaction( 'ProcessReturn' );
- $gateway->addResponseData( array(
- 'result' => '8', // rejected by bank
- 'x_amount' => '100.00',
- 'x_amount_usd' => '42.05',
- 'x_control' =>
'706F57BC3E74906B14B1DEB946F027104513797CC62AC0F5107BC98F42D5DC95',
- 'x_description' => 'Donation to the Wikimedia
Foundation',
- 'x_document' => '32869',
- 'x_iduser' => '08feb2d12771bbcfeb86',
- 'x_invoice' => '123456789',
- ) );
-
- $result = $gateway->processResponse( null );
- $status = $gateway->getFinalStatus();
- $this->assertNull( $result );
- $this->assertEquals( 'failed', $status );
- }
-}
->>>>>>> BRANCH (539a01 Astropay result switcher)
diff --git a/tests/DonationQueueTest.php b/tests/DonationQueueTest.php
deleted file mode 100644
index 8aabe05..0000000
--- a/tests/DonationQueueTest.php
+++ /dev/null
@@ -1,151 +0,0 @@
-<?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 DonationInterface
- * @group QueueHandling
- *
- * @category UnitTesting
- * @package Fundraising_QueueHandling
- */
-class DonationQueueTest extends DonationInterfaceTestCase {
- protected $transaction;
- protected $queue_name;
- protected $expected_message;
-
- public function setUp() {
- parent::setUp();
-
- $this->queue_name = 'test-' . mt_rand();
-
- $this->setMwGlobals( array(
- 'wgDonationInterfaceEnableQueue' => true,
- 'wgDonationInterfaceDefaultQueueServer' => array(
- 'type' => 'TestingQueue',
- ),
- 'wgDonationInterfaceQueues' => array(
- $this->queue_name => array(),
- ),
- ) );
-
- $this->transaction = array(
- 'amount' => '1.24',
- 'city' => 'Dunburger',
- 'contribution_tracking_id' => mt_rand(),
- // FIXME: err, we're cheating normalization here.
- 'correlation-id' => 'testgateway-' . mt_rand(),
- 'country' => 'US',
- 'currency_code' => 'USD',
- 'date' => time(),
- 'email' => '[email protected]',
- 'fname' => 'Jen',
- 'gateway_account' => 'default',
- 'gateway' => 'testgateway',
- 'gateway_txn_id' => mt_rand(),
- 'language' => 'en',
- 'lname' => 'Russ',
- 'payment_method' => 'cc',
- 'payment_submethod' => 'visa',
- 'php-message-class' =>
'SmashPig\CrmLink\Messages\DonationInterfaceMessage',
- 'referrer' => 'http://localhost.net/Ref',
- 'response' => 'Gateway response something',
- 'state' => 'AK',
- 'street' => '1 Fake St.',
- 'user_ip' => '127.0.0.1',
- 'utm_source' => 'testing',
- 'zip' => '12345',
- );
-
- $this->expected_message = array(
- 'contribution_tracking_id' =>
$this->transaction['contribution_tracking_id'],
- 'utm_source' => 'testing',
- 'language' => 'en',
- 'referrer' => 'http://localhost.net/Ref',
- 'email' => '[email protected]',
- 'first_name' => 'Jen',
- 'last_name' => 'Russ',
- 'street_address' => '1 Fake St.',
- 'city' => 'Dunburger',
- 'state_province' => 'AK',
- 'country' => 'US',
- 'postal_code' => '12345',
- 'gateway' => 'testgateway',
- 'gateway_account' => 'default',
- 'gateway_txn_id' =>
$this->transaction['gateway_txn_id'],
- 'payment_method' => 'cc',
- 'payment_submethod' => 'visa',
- 'response' => 'Gateway response something',
- 'currency' => 'USD',
- 'fee' => '0',
- 'gross' => '1.24',
- 'user_ip' => '127.0.0.1',
- 'date' => (int)$this->transaction['date'],
- );
- }
-
- public function tearDown() {
- // Clear static variables.
- TestingQueue::clearAll();
-
- parent::tearDown();
- }
-
- public function testPushMessage() {
- DonationQueue::instance()->push( $this->transaction,
$this->queue_name );
-
- $this->assertEquals( $this->expected_message,
- DonationQueue::instance()->pop( $this->queue_name ) );
- }
-
- /**
- * After pushing 2, pop should return the first.
- */
- public function testIsFifoQueue() {
- DonationQueue::instance()->push( $this->transaction,
$this->queue_name );
-
- $transaction2 = $this->transaction;
- $transaction2['correlation-id'] = mt_rand();
-
- $this->assertEquals( $this->expected_message,
- DonationQueue::instance()->pop( $this->queue_name ) );
- }
-
- public function testSetMessage() {
- DonationQueue::instance()->set(
$this->transaction['correlation-id'],
- $this->transaction, $this->queue_name );
-
- $this->assertEquals( $this->expected_message,
- DonationQueue::instance()->get(
- $this->transaction['correlation-id'],
$this->queue_name ) );
- }
-
- public function testDeleteMessage() {
- DonationQueue::instance()->set(
$this->transaction['correlation-id'],
- $this->transaction, $this->queue_name );
- $this->assertEquals( $this->expected_message,
- DonationQueue::instance()->get(
- $this->transaction['correlation-id'],
$this->queue_name ) );
-
- DonationQueue::instance()->delete(
- $this->transaction['correlation-id'], $this->queue_name
);
-
- $this->assertNull(
- DonationQueue::instance()->get(
- $this->transaction['correlation-id'],
$this->queue_name ) );
- }
-}
diff --git a/tests/includes/Responses/astropay/PaymentStatus.testresponse
b/tests/includes/Responses/astropay/PaymentStatus.testresponse
deleted file mode 100644
index b3bfcc5..0000000
--- a/tests/includes/Responses/astropay/PaymentStatus.testresponse
+++ /dev/null
@@ -1,9 +0,0 @@
-HTTP/1.1 200 OK
-Server: nginx/1.7.9
-Date: Wed, 08 Apr 2015 00:19:52 GMT
-Content-Type: text/plain; charset=UTF-8
-Content-Length: 130
-Connection: keep-alive
-X-Powered-By: PHP/5.3.27
-
-9|08feb2d12771bbcfeb86|123456789|100.00|1|0656B92DF44B814D48D84FED2F444CCA1E991A24A365FBEECCCA15B73CC08C2A|987654321|TE|03|GNB|BRL
diff --git
a/tests/includes/Responses/astropay/PaymentStatus_badsig.testresponse
b/tests/includes/Responses/astropay/PaymentStatus_badsig.testresponse
deleted file mode 100644
index 3fa91dc..0000000
--- a/tests/includes/Responses/astropay/PaymentStatus_badsig.testresponse
+++ /dev/null
@@ -1,9 +0,0 @@
-HTTP/1.1 200 OK
-Server: nginx/1.7.9
-Date: Wed, 08 Apr 2015 00:19:52 GMT
-Content-Type: text/plain; charset=UTF-8
-Content-Length: 130
-Connection: keep-alive
-X-Powered-By: PHP/5.3.27
-
-9|08feb2d12771bbcfeb86|123456789|100.00|1|BadSignature|987654321|TE|03|GNB|BRL
diff --git a/tests/includes/TestingQueue.php b/tests/includes/TestingQueue.php
deleted file mode 100644
index 1e343ee..0000000
--- a/tests/includes/TestingQueue.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?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.
- *
- */
-
-/*
-FIXME: We can't reference the actual classes until vendor/ is provisioned for
tests.
-
-use PHPQueue\Backend\Base;
-use PHPQueue\Interfaces\KeyValueStore;
-use PHPQueue\Interfaces\IndexedFifoQueueStore;
-*/
-
-/**
- * Queue backend that uses a simple static variable. Supports all operations
- * and multiple queues, but (obviously) data is destroyed on application
- * shutdown.
- */
-class TestingQueue
- /*
- extends Base
- implements IndexedFifoQueueStore, KeyValueStore
- */
-{
- protected $queue_name;
- protected $queue;
-
- public static $queues = array();
-
- public function __construct($options=array()) {
- //parent::__construct();
- if (!empty($options['queue'])) {
- $this->queue_name = $options['queue'];
- } else {
- $this->queue_name = 'default';
- }
- // Make me specific.
- if ( !array_key_exists( $this->queue_name, self::$queues ) ) {
- self::$queues[$this->queue_name] = array();
- }
- $this->queue = &self::$queues[$this->queue_name];
- }
-
- public static function clearAll() {
- self::$queues = array();
- }
-
- public function push( $data ) {
- $this->queue[] = json_encode( $data );
- return count( $this->queue ) - 1;
- }
-
- public function pop() {
- if ( !count( $this->queue ) ) {
- return null;
- }
- return json_decode( array_shift( $this->queue ), true );
- }
-
- public function set( $id, $data ) {
- $this->queue[$id] = json_encode( $data );
- }
-
- public function get( $id ) {
- if ( !array_key_exists( $id, $this->queue ) ) {
- return null;
- }
- return json_decode( $this->queue[$id], true );
- }
-
- public function clear( $id ) {
- if ( array_key_exists( $id, $this->queue ) ) {
- unset( $this->queue[$id] );
- }
- }
-}
--
To view, visit https://gerrit.wikimedia.org/r/206179
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I12557822293e79b37da1bafce344dcb5c32b5138
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: deployment
Gerrit-Owner: Awight <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits