Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/199669
Change subject: Merge master into deployment ...................................................................... Merge master into deployment 702e532f582fbb2e3b699f673d640e6180017550 Clean up some Adyen cruft 99bb608adea57557c02d484a54502548dc470312 Test that we are skipping the PP interstitial 39a462d9edc1f7f5d1bbda33f824c31a0f63f1d0 Zoom out PayPal integration tests c01dbf89b8fa0668726c9d15c9665ccce8277778 Localisation updates from https://translatewiki.net. 65239f54db6d1a124d3994d4523d8e89e6a476bd Localisation updates from https://translatewiki.net. 5508781dfc002eed344acd985000d3c8c8d8849d Localisation updates from https://translatewiki.net. 600b5a74867cdab08ab6d8335dc096df1c24634b Localisation updates from https://translatewiki.net. c12b1b9cb70650b71d1f2696f3e3ca241fbd0288 Don't do stupid things with the recurring param Change-Id: Idb560491c4d34638402627dde56fc3c7bfa06b6f --- D tests/Adapter/PayPal/PayPalTest.php D tests/includes/test_gateway/TestingPaypalAdapter.php 2 files changed, 0 insertions(+), 347 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/69/199669/1 diff --git a/tests/Adapter/PayPal/PayPalTest.php b/tests/Adapter/PayPal/PayPalTest.php deleted file mode 100644 index 352b614..0000000 --- a/tests/Adapter/PayPal/PayPalTest.php +++ /dev/null @@ -1,275 +0,0 @@ -<<<<<<< HEAD (309ff1 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. - */ - -/** - * - * @group Fundraising - * @group DonationInterface - * @group PayPal - */ -class DonationInterface_Adapter_PayPal_Test 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 - */ - public function __construct( $name = null, array $data = array(), $dataName = '' ) { - parent::__construct( $name, $data, $dataName ); - $this->testAdapterClass = 'TestingPaypalAdapter'; - } - - public function tearDown() { - TestingPaypalAdapter::$fakeGlobals = array(); - - parent::tearDown(); - } - - /** - * Integration test to verify that the Donate transaction works as expected when all necessary data is present. - */ - function testDoTransactionDonate() { - $init = $this->getDonorTestData(); - $gateway = $this->getFreshGatewayObject( $init ); - - $ret = $gateway->doPayment(); - parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), $res ); - - $expected = array ( - 'amount' => $init['amount'], - 'currency_code' => $init['currency_code'], - 'country' => $init['country'], - 'business' => '[email protected]', - 'cmd' => '_donations', - 'item_name' => 'Donation to the Wikimedia Foundation', - 'item_number' => 'DONATE', - 'no_note' => '0', - 'custom' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'lc' => $init['country'], //this works because it's a US donor... - 'cancel_return' => $gateway->getGlobal( 'ReturnURL' ), - 'return' => $gateway->getGlobal( 'ReturnURL' ), - ); - - $this->assertEquals( $expected, $res, 'Paypal "Donate" transaction not constructing the expected redirect URL' ); - $this->assertNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), "Paypal order_id is not null, and we shouldn't be generating one" ); - } - - /** - * Integration test to verify that the DonateRecurring transaction works as expected when all necessary data is present. - */ - function testDoTransactionDonateRecurring() { - $init = $this->getDonorTestData(); - $init['recurring'] = '1'; - $gateway = $this->getFreshGatewayObject( $init ); - - $ret = $gateway->doPayment(); - parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), $res ); - - $expected = array ( - 'a3' => $init['amount'], //obviously. - 'currency_code' => $init['currency_code'], - 'country' => $init['country'], - 'business' => '[email protected]', - 'cmd' => '_xclick-subscriptions', - 'item_name' => 'Donation to the Wikimedia Foundation', - 'item_number' => 'DONATE', - 'no_note' => '0', - 'custom' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'lc' => $init['country'], //this works because it's a US donor... - 't3' => 'M', //hard-coded in transaction definition - 'p3' => '1', //hard-coded in transaction definition - 'src' => '1', //hard-coded in transaction definition - 'srt' => $gateway->getGlobal( 'RecurringLength' ), - 'cancel_return' => $gateway->getGlobal( 'ReturnURL' ), - 'return' => $gateway->getGlobal( 'ReturnURL' ), - ); - - $this->assertEquals( $expected, $res, 'Paypal "DonateRecurring" transaction not constructing the expected redirect URL' ); - } - - /** - * Integration test to verify that the Donate transaction works as expected when all necessary data is present. - */ - function testDoTransactionDonateXclick() { - $init = $this->getDonorTestData(); - - TestingPaypalAdapter::$fakeGlobals = array( - 'XclickCountries' => array( $init['country'] ), - ); - - $gateway = $this->getFreshGatewayObject( $init ); - - $ret = $gateway->doPayment(); - parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), $res ); - - $expected = array ( - 'amount' => $init['amount'], - 'currency_code' => $init['currency_code'], - 'country' => $init['country'], - 'business' => '[email protected]', - 'cmd' => '_xclick', - 'item_name' => 'Donation to the Wikimedia Foundation', - 'item_number' => 'DONATE', - 'no_note' => '1', //hard-coded in transaction definition - 'custom' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), -// 'lc' => $init['country'], //Apparently, this was removed from our implementation, because 'CN' is weird. - 'cancel_return' => $gateway->getGlobal( 'ReturnURL' ), - 'return' => $gateway->getGlobal( 'ReturnURL' ), - 'no_shipping' => '1', //hard-coded in transaction definition - ); - - $this->assertEquals( $expected, $res, 'Paypal "DonateXclick" transaction not constructing the expected redirect URL' ); - } - - /** - * Integration test to verify that the Paypal gateway redirects when validation is successful. - */ - function testRedirectFormOnValid() { - $init = $this->getDonorTestData(); - $_SESSION['Donor'] = $init; - - $that = $this; - $redirectTest = function( $location ) use ( $that, $init ) { - parse_str( parse_url( $location, PHP_URL_QUERY ), $actual ); - $that->assertEquals( $init['amount'], $actual['amount'] ); - }; - $assertNodes = array( - 'headers' => array( - 'Location' => $redirectTest, - ) - ); - - $this->verifyFormOutput( 'PaypalGateway', $init, $assertNodes, false ); - } - - /** - * Integration test to verify that the Paypal gateway shows an error message when validation fails. - */ - function testShowFormOnError() { - $init = $this->getDonorTestData(); - $init['amount'] = '-100.00'; - $_SESSION['Donor'] = $init; - $errorMessage = wfMessage('donate_interface-error-msg-field-correction', wfMessage('donate_interface-error-msg-amount')->text())->text(); - $assertNodes = array( - 'mw-content-text' => array( - 'innerhtmlmatches' => "/.*$errorMessage.*/" - ) - ); - - $this->verifyFormOutput( 'PaypalGateway', $init, $assertNodes, false ); - } - - /** - * Integration test to verify that the Donate transaction works as expected in Belgium for fr, de, and nl. - * - * @dataProvider belgiumLanguageProvider - */ - function testDoTransactionDonate_BE( $language ) { - $init = $this->getDonorTestData( 'BE' ); - $init['language'] = $language; - $this->setLanguage( $language ); - $gateway = $this->getFreshGatewayObject( $init ); - $donateText = wfMessage( 'donate_interface-donation-description' )->inLanguage( $language )->text(); - $ret = $gateway->doPayment(); - parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), $res ); - - $expected = array ( - 'amount' => $init['amount'], - 'currency_code' => $init['currency_code'], - 'country' => 'BE', - 'business' => '[email protected]', - 'cmd' => '_donations', - 'item_name' => $donateText, - 'item_number' => 'DONATE', - 'no_note' => '0', - 'custom' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'lc' => $init['country'], //this works because it's a US donor... - 'cancel_return' => $gateway->getGlobal( 'ReturnURL' ), - 'return' => $gateway->getGlobal( 'ReturnURL' ), - ); - - $this->assertEquals( $expected, $res, 'Paypal "Donate" transaction not constructing the expected redirect URL' ); - $this->assertNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), "Paypal order_id is not null, and we shouldn't be generating one" ); - } - - /** - * Integration test to verify that the Donate transaction works as expected - * in Canada for English and French - * - * @dataProvider belgiumLanguageProvider - */ - function testDoTransactionDonate_CA( $language ) { - $init = $this->getDonorTestData( 'CA' ); - $init['language'] = $language; - $this->setLanguage( $language ); - $gateway = $this->getFreshGatewayObject( $init ); - $donateText = wfMessage( 'donate_interface-donation-description' )->inLanguage( $language )->text(); - $ret = $gateway->doPayment(); - parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), $res ); - - $expected = array ( - 'amount' => $init['amount'], - 'currency_code' => 'CAD', - 'country' => 'CA', - 'business' => '[email protected]', - 'cmd' => '_donations', - 'item_name' => $donateText, - 'item_number' => 'DONATE', - 'no_note' => '0', - 'custom' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'lc' => 'CA', - 'cancel_return' => $gateway->getGlobal( 'ReturnURL' ), - 'return' => $gateway->getGlobal( 'ReturnURL' ), - ); - - $this->assertEquals( $expected, $res, 'Paypal "Donate" transaction not constructing the expected redirect URL' ); - $this->assertNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), "Paypal order_id is not null, and we shouldn't be generating one" ); - } - - /** - * Integration test to verify that the Donate transaction works as expected in Italy - */ - function testDoTransactionDonate_IT() { - $init = $this->getDonorTestData( 'IT' ); - $this->setLanguage( 'it' ); - $gateway = $this->getFreshGatewayObject( $init ); - $donateText = wfMessage( 'donate_interface-donation-description' )->inLanguage( 'it' )->text(); - $ret = $gateway->doPayment(); - parse_str( parse_url( $ret->getRedirect(), PHP_URL_QUERY ), $res ); - - $expected = array ( - 'amount' => $init['amount'], - 'currency_code' => $init['currency_code'], - 'country' => 'IT', - 'business' => '[email protected]', - 'cmd' => '_donations', - 'item_name' => $donateText, - 'item_number' => 'DONATE', - 'no_note' => '0', - 'custom' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'lc' => 'IT', - 'cancel_return' => $gateway->getGlobal( 'ReturnURL' ), - 'return' => $gateway->getGlobal( 'ReturnURL' ), - ); - - $this->assertEquals( $expected, $res, 'Paypal "Donate" transaction not constructing the expected redirect URL' ); - $this->assertNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), "Paypal order_id is not null, and we shouldn't be generating one" ); - } -} ->>>>>>> BRANCH (c12b1b Don't do stupid things with the recurring param) diff --git a/tests/includes/test_gateway/TestingPaypalAdapter.php b/tests/includes/test_gateway/TestingPaypalAdapter.php deleted file mode 100644 index eac1257..0000000 --- a/tests/includes/test_gateway/TestingPaypalAdapter.php +++ /dev/null @@ -1,72 +0,0 @@ -<<<<<<< HEAD (309ff1 Merge master into deployment) -======= -<?php - -/** - * TestingPaypalAdapter - * @TODO: Extend/damage things here. I'm sure we'll need it eventually... - */ -class TestingPaypalAdapter extends PaypalAdapter { - public static $fakeGlobals = array(); - - /** - * Set the error code you want the dummy response to return - */ - 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, - ); - } - - public static function getGlobal( $name ) { - if ( array_key_exists( $name, TestingPaypalAdapter::$fakeGlobals ) ) { - return TestingPaypalAdapter::$fakeGlobals[$name]; - } - return parent::getGlobal( $name ); - } -} ->>>>>>> BRANCH (c12b1b Don't do stupid things with the recurring param) -- To view, visit https://gerrit.wikimedia.org/r/199669 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idb560491c4d34638402627dde56fc3c7bfa06b6f 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
