jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/347406 )
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment And make vendor match currently deployed version 601042e Update smashpig dd35620 Localisation updates from https://translatewiki.net. 16b47a2 Localisation updates from https://translatewiki.net. e6ba951 Reset SmashPig lib to currently deployed version Change-Id: I78adb59681ca4028599b9cff2832480a65b4d264 --- D tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php M vendor 2 files changed, 1 insertion(+), 222 deletions(-) Approvals: jenkins-bot: Verified Ejegg: Looks good to me, approved diff --git a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php deleted file mode 100644 index a56cfca..0000000 --- a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectOrphanRectifierTest.php +++ /dev/null @@ -1,221 +0,0 @@ -<<<<<<< HEAD (ef0862 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 SmashPig\Core\Context; -use SmashPig\Core\DataStores\PendingDatabase; -use SmashPig\Tests\SmashPigDatabaseTestConfiguration; - -/** - * @covers GlobalCollectOrphanRectifier - * - * @group Fundraising - * @group DonationInterface - * @group GlobalCollect - * @group OrphanSlayer - */ -class DonationInterface_Adapter_GlobalCollect_Orphan_Rectifier_Test - extends DonationInterfaceTestCase -{ - // TODO: Give vulgar names. - // FIXME: Is 25 the normal unauthorized status? Use the common one, whatever that is. - const STATUS_PENDING = 25; - const STATUS_PENDING_POKE = 600; - const STATUS_COMPLETE = 800; - - // Arbitrary configuration for testing time logic. - const TIME_BUFFER = 60; - const TARGET_EXECUTE_TIME = 1200; - - public $pendingDb; - - public function setUp() { - parent::setUp(); - - $this->setMwGlobals( array( - 'wgDonationInterfaceOrphanCron' => array( - 'enable' => true, - 'target_execute_time' => self::TARGET_EXECUTE_TIME, - 'time_buffer' => self::TIME_BUFFER, - ), - 'wgGlobalCollectGatewayEnabled' => true, - 'wgDonationInterfaceGatewayAdapters' => array( - // We include the regular adapter in order to pass gateway validation D: - 'globalcollect' => 'TestingGlobalCollectOrphanAdapter', - 'globalcollect_orphan' => 'TestingGlobalCollectOrphanAdapter', - ), - ) ); - - $config = SmashPigDatabaseTestConfiguration::instance(); - Context::init( $config ); - - $this->pendingDb = PendingDatabase::get(); - - // Create the schema. - $this->pendingDb->createTable(); - } - - /** - * When leaving a message unprocessed and pending, don't try to process it - * again. - */ - public function testProcessOrphansStatusPending() { - $orphan_pending = $this->createOrphan(); - - $rectifier = new GlobalCollectOrphanRectifier(); - $this->gateway = $rectifier->getAdapter(); - $this->gateway->setDummyGatewayResponseCode( self::STATUS_PENDING ); - $rectifier->processOrphans(); - - $fetched = $this->pendingDb->fetchMessageByGatewayOrderId( - 'globalcollect', $orphan_pending['order_id'] ); - $this->assertNull( $fetched, - 'Message was popped.' ); - - $this->assertGatewayCallsExactly( array( - 'GET_ORDERSTATUS' - ) ); - } - - /** - * If a message is waiting for the API kiss of death, perform it. - */ - public function testProcessOrphansStatusPendingPoke() { - $orphan_pending_poke = $this->createOrphan(); - - $rectifier = new GlobalCollectOrphanRectifier(); - $this->gateway = $rectifier->getAdapter(); - $this->gateway->setDummyGatewayResponseCode( self::STATUS_PENDING_POKE ); - $rectifier->processOrphans(); - - $fetched = $this->pendingDb->fetchMessageByGatewayOrderId( - 'globalcollect', $orphan_pending_poke['order_id'] ); - $this->assertNull( $fetched, - 'Message was popped' ); - - $this->assertGatewayCallsExactly( array( - 'GET_ORDERSTATUS', - 'SET_PAYMENT', - ) ); - - // TODO: test that we sent a completion message - } - - /** - * Report a completed transaction. - */ - public function testProcessOrphansStatusComplete() { - - $orphan_complete = $this->createOrphan(); - - $rectifier = new GlobalCollectOrphanRectifier(); - $this->gateway = $rectifier->getAdapter(); - $this->gateway->setDummyGatewayResponseCode( self::STATUS_COMPLETE ); - $rectifier->processOrphans(); - - $fetched = $this->pendingDb->fetchMessageByGatewayOrderId( - 'globalcollect', $orphan_complete['order_id'] ); - $this->assertNull( $fetched, - 'Message was popped' ); - - $this->assertGatewayCallsExactly( array( - 'GET_ORDERSTATUS', - ) ); - - // TODO: test that we sent a completion message - } - - /** - * Don't process recent messages. - */ - public function testTooRecentMessage() { - $orphan_complete = $this->createOrphan( array( - 'date' => time() - self::TIME_BUFFER + 30, - ) ); - - $rectifier = new GlobalCollectOrphanRectifier(); - $this->gateway = $rectifier->getAdapter(); - $rectifier->processOrphans(); - - $fetched = $this->pendingDb->fetchMessageByGatewayOrderId( - 'globalcollect', $orphan_complete['order_id'] ); - $this->assertNotNull( $fetched, - 'Message was not popped' ); - - $this->assertGatewayCallsExactly( array() ); - - // TODO: Test that we: - // * Logged the "done with old messages" line. - } - - /** - * Create an orphaned tranaction and store it to the pending database. - * - * TODO: Reuse SmashPigBaseTest#createMessage - */ - public function createOrphan( $overrides = array() ) { - $uniq = mt_rand(); - $message = $overrides + array( - 'contribution_tracking_id' => $uniq, - 'fname' => 'Flighty', - 'lname' => 'Dono', - 'email' => 'test+...@eff.org', - 'gateway' => 'globalcollect', - 'gateway_txn_id' => "txn-{$uniq}", - 'order_id' => "order-{$uniq}", - 'gateway_account' => 'default', - 'payment_method' => 'cc', - 'payment_submethod' => 'mc', - // Defaults to a magic 25 minutes ago, within the process window. - 'date' => time() - 25 * 60, - 'amount' => 123, - 'currency' => 'EUR', - ); - $this->pendingDb->storeMessage( $message ); - return $message; - } - - /** - * Assert whether we made exactly the expected gateway calls - * - * @param array $expected List of API action names, in the form they appear - * in the <ACTION> tag. - */ - protected function assertGatewayCallsExactly( $expected ) { - $expected_num_calls = count( $expected ); - $this->assertEquals( $expected_num_calls, count( $this->gateway->curled ), - "Ran exactly {$expected_num_calls} API calls" ); - foreach ( $expected as $index => $action ) { - $this->assertRegExp( '/\b' . $action . '\b/', $this->gateway->curled[$index], - "Call #" . ( $index + 1 ) . " was {$action}." ); - } - } - - /** - * Dump the entire database state, for debugging. - */ - protected function debugDbContents() { - $result = $this->pendingDb->getDatabase()->query( - "select * from pending" ); - $rows = $result->fetchAll( PDO::FETCH_ASSOC ); - var_export($rows); - } -} ->>>>>>> BRANCH (e6ba95 Reset SmashPig lib to currently deployed version) diff --git a/vendor b/vendor index 13319ac..145de2a 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 13319acc0cf5d03b95e8b1024d9f1f8504971041 +Subproject commit 145de2a81260066518539ceed410eb6ec615b663 -- To view, visit https://gerrit.wikimedia.org/r/347406 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I78adb59681ca4028599b9cff2832480a65b4d264 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Awight <awi...@wikimedia.org> Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org> Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits