Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/343732 )
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment And update vendor a1ec96b Copy accepted currencies from PayPal legacy to express checkout 7728083 More verbose test titles 5796f47 Comments and whitespace 71acea7 Check for maintenance mode before anything 68e2fac Comments d7a0445 Localisation updates from https://translatewiki.net. 6d573ef Localisation updates from https://translatewiki.net. 957137b Update smashpig lib Change-Id: Id2625cb82c7221e3681b92a5c68dc50bbab42ac1 --- D tests/phpunit/GatewayPageTest.php M vendor 2 files changed, 1 insertion(+), 214 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/32/343732/1 diff --git a/tests/phpunit/GatewayPageTest.php b/tests/phpunit/GatewayPageTest.php deleted file mode 100644 index a76a6da..0000000 --- a/tests/phpunit/GatewayPageTest.php +++ /dev/null @@ -1,213 +0,0 @@ -<<<<<<< HEAD (84aa10 Merge branch '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 GatewayPage - */ -class GatewayPageTest extends DonationInterfaceTestCase { - - /** - * @var GatewayPage - */ - protected $page; - /** - * @var GatewayAdapter - */ - protected $adapter; - - public function setUp() { - $this->page = new TestingGatewayPage(); - // put these here so tests can override them - TestingGenericAdapter::$fakeGlobals = array ( 'FallbackCurrency' => 'USD' ); - TestingGenericAdapter::$acceptedCurrencies[] = 'USD'; - TestingGenericAdapter::$fakeIdentifier = 'globalcollect'; - $this->setMwGlobals( array( - 'wgPaypalGatewayEnabled' => true, - 'wgDonationInterfaceAllowedHtmlForms' => array( - 'paypal' => array( - 'gateway' => 'paypal', - 'payment_methods' => array('paypal' => 'ALL'), - ), - ), - ) ); - parent::setUp(); - } - - protected function setUpAdapter( $extra = array() ) { - $externalData = array_merge( - array( - 'amount' => '200', - 'currency_code' => 'BBD', - 'contribution_tracking_id' => mt_rand( 10000, 10000000 ), - ), - $extra - ); - $this->adapter = new TestingGenericAdapter( array( - 'external_data' => $externalData, - ) ); - $this->page->adapter = $this->adapter; - } - - public function tearDown() { - TestingGenericAdapter::$acceptedCurrencies = array(); - TestingGenericAdapter::$fakeGlobals = array(); - TestingGenericAdapter::$fakeIdentifier = false; - parent::tearDown(); - } - - public function testCurrencyFallbackWithNotification() { - TestingGenericAdapter::$fakeGlobals['NotifyOnConvert'] = true; - $this->setUpAdapter(); - - $this->page->validateForm(); - - $this->assertTrue( $this->adapter->validatedOK() ); - - $manualErrors = $this->adapter->getManualErrors(); - $msg = $this->page->msg( 'donate_interface-fallback-currency-notice', 'USD' )->text(); - $this->assertEquals( $msg, $manualErrors['general'] ); - $this->assertEquals( 100, $this->adapter->getData_Unstaged_Escaped( 'amount' ) ); - $this->assertEquals( 'USD', $this->adapter->getData_Unstaged_Escaped( 'currency_code' ) ); - } - - public function testCurrencyFallbackIntermediateConversion() { - TestingGenericAdapter::$fakeGlobals['FallbackCurrency'] = 'OMR'; - TestingGenericAdapter::$fakeGlobals['NotifyOnConvert'] = true; - TestingGenericAdapter::$acceptedCurrencies[] = 'OMR'; - // FIXME: Relies on app default exchange rate. Set explicitly instead. - $this->setUpAdapter(); - - $this->page->validateForm(); - - $manualErrors = $this->adapter->getManualErrors(); - $msg = $this->page->msg( 'donate_interface-fallback-currency-notice', 'OMR' )->text(); - $this->assertEquals( $msg, $manualErrors['general'] ); - $this->assertEquals( 38, $this->adapter->getData_Unstaged_Escaped( 'amount' ) ); - $this->assertEquals( 'OMR', $this->adapter->getData_Unstaged_Escaped( 'currency_code' ) ); - } - - public function testCurrencyFallbackWithoutNotification() { - TestingGenericAdapter::$fakeGlobals['NotifyOnConvert'] = false; - $this->setUpAdapter(); - - $this->page->validateForm(); - - $this->assertTrue( $this->adapter->validatedOK() ); - - $manualErrors = $this->adapter->getManualErrors(); - $this->assertEquals( null, $manualErrors['general'] ); - $this->assertEquals( 100, $this->adapter->getData_Unstaged_Escaped( 'amount' ) ); - $this->assertEquals( 'USD', $this->adapter->getData_Unstaged_Escaped( 'currency_code' ) ); - } - - public function testCurrencyFallbackAlwaysNotifiesIfOtherErrors() { - TestingGenericAdapter::$fakeGlobals['NotifyOnConvert'] = false; - $this->setUpAdapter( array( 'email' => 'notanemail' ) ); - - $this->page->validateForm(); - - $manualErrors = $this->adapter->getManualErrors(); - $msg = $this->page->msg( 'donate_interface-fallback-currency-notice', 'USD' )->text(); - $this->assertEquals( $msg, $manualErrors['general'] ); - $this->assertEquals( 100, $this->adapter->getData_Unstaged_Escaped( 'amount' ) ); - $this->assertEquals( 'USD', $this->adapter->getData_Unstaged_Escaped( 'currency_code' ) ); - } - - public function testNoFallbackForSupportedCurrency() { - TestingGenericAdapter::$acceptedCurrencies[] = 'BBD'; - $this->setUpAdapter(); - - $this->page->validateForm(); - - $manualErrors = $this->adapter->getManualErrors(); - $this->assertEquals( null, $manualErrors['general'] ); - $this->assertEquals( 200, $this->adapter->getData_Unstaged_Escaped( 'amount' ) ); - $this->assertEquals( 'BBD', $this->adapter->getData_Unstaged_Escaped( 'currency_code' ) ); - } - - public function testCurrencyFallbackByCountry() { - // With 'FallbackCurrencyByCountry', we need to return a single supported currency - TestingGenericAdapter::$acceptedCurrencies = array( 'USD' ); - TestingGenericAdapter::$fakeGlobals = array( - 'FallbackCurrency' => false, - 'FallbackCurrencyByCountry' => true, - ); - $this->setUpAdapter(); - $this->adapter->addRequestData( array( - 'country' => 'US', - ) ); - - $this->page->validateForm(); - - $this->assertEquals( 100, $this->adapter->getData_Unstaged_Escaped( 'amount' ) ); - $this->assertEquals( 'USD', $this->adapter->getData_Unstaged_Escaped( 'currency_code' ) ); - } - - /** - * Before redirecting a user to the processor, we should log all of their - * details at info level - */ - function testLogDetailsOnRedirect() { - $init = $this->getDonorTestData(); - $session = array( 'Donor' => $init ); - - $this->verifyFormOutput( 'PaypalLegacyGateway', $init, array(), false, $session ); - - $logged = $this->getLogMatches( LogLevel::INFO, '/^Redirecting for transaction: /' ); - $this->assertEquals( 1, count( $logged ), 'Should have logged details once' ); - preg_match( '/Redirecting for transaction: (.*)$/', $logged[0], $matches ); - $detailString = $matches[1]; - $expected = array( - 'currency_code' => 'USD', - 'payment_submethod' => '', - 'fname' => 'Firstname', - 'lname' => 'Surname', - 'amount' => '1.55', - 'language' => 'en', - 'email' => 'nob...@wikimedia.org', - 'country' => 'US', - 'payment_method' => 'paypal', - 'user_ip' => '127.0.0.1', - 'recurring' => '', - 'utm_source' => '..paypal', - 'gateway' => 'paypal', - 'gateway_account' => 'testing', - 'gateway_txn_id' => false, - 'response' => false, - 'street' => '123 Fake Street', - 'city' => 'San Francisco', - 'state' => 'CA', - 'postal_code' => '94105', - 'php-message-class' => 'SmashPig\CrmLink\Messages\DonationInterfaceMessage', - ); - $actual = json_decode( $detailString, true ); - // TODO: when tests use PHPUnit 4.4 - // $this->assertArraySubset( $expected, $actual, false, 'Logged the wrong stuff' ); - $expected['order_id'] = $actual['contribution_tracking_id']; - unset( $actual['contribution_tracking_id'] ); - unset( $actual['correlation-id'] ); - unset( $actual['date'] ); - $this->assertEquals( $expected, $actual, 'Logged the wrong stuff!' ); - } -} ->>>>>>> BRANCH (957137 Update smashpig lib) diff --git a/vendor b/vendor index 9744ca0..145de2a 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 9744ca0309906899fbaa1e3582ca14243e19d7ba +Subproject commit 145de2a81260066518539ceed410eb6ec615b663 -- To view, visit https://gerrit.wikimedia.org/r/343732 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id2625cb82c7221e3681b92a5c68dc50bbab42ac1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits