jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/316500 )
Change subject: Test a bit of Amazon queue stuff ...................................................................... Test a bit of Amazon queue stuff Less fakery in the test adapters, more accurately testing what actually will go out over the wire. SHOULD be able to use the php-queue PDO backend with in-memory sqlite db, but that's sometimes a pain to reset. Change-Id: I948ef7e3c02f35563bf1868a003fe3c838de4f29 --- M DonationInterface.class.php M tests/phpunit/Adapter/Amazon/AmazonTest.php M tests/phpunit/DonationInterfaceTestCase.php M tests/phpunit/DonationQueueTest.php M tests/phpunit/TestConfiguration.php M tests/phpunit/includes/test_gateway/TestingAmazonAdapter.php 6 files changed, 13 insertions(+), 28 deletions(-) Approvals: XenoRyet: Looks good to me, approved jenkins-bot: Verified diff --git a/DonationInterface.class.php b/DonationInterface.class.php index 9132a26..5fcc120 100644 --- a/DonationInterface.class.php +++ b/DonationInterface.class.php @@ -50,7 +50,7 @@ $testDir = __DIR__ . '/tests/phpunit/'; // Set up globaltown - require_once $testDir . '/TestConfiguration.php'; + require_once $testDir . 'TestConfiguration.php'; $files[] = $testDir . 'AllTests.php'; diff --git a/tests/phpunit/Adapter/Amazon/AmazonTest.php b/tests/phpunit/Adapter/Amazon/AmazonTest.php index 8284d51..7ecc246 100644 --- a/tests/phpunit/Adapter/Amazon/AmazonTest.php +++ b/tests/phpunit/Adapter/Amazon/AmazonTest.php @@ -149,9 +149,8 @@ $this->assertEquals( $oid, $setOrderReferenceDetailsArgs['seller_order_id'], 'Did not set order id on order reference' ); $this->assertEquals( $init['amount'], $setOrderReferenceDetailsArgs['amount'], 'Did not set amount on order reference' ); $this->assertEquals( $init['currency_code'], $setOrderReferenceDetailsArgs['currency_code'], 'Did not set currency code on order reference' ); - $queued = $gateway->queue_messages; - $this->assertNotEmpty( $queued['complete'], 'Not sending a message to the complete queue' ); - $message = $queued['complete'][0]; + $message = DonationQueue::instance()->pop( 'complete' ); + $this->assertNotNull( $message, 'Not sending a message to the complete queue' ); $this->assertEquals( 'S01-0391295-0674065-C095112', $message['gateway_txn_id'], 'Queue message has wrong txn ID' ); } @@ -273,9 +272,8 @@ $authorizeOnBillingAgreementDetailsArgs = $mockClient->calls['authorizeOnBillingAgreement'][0]; $this->assertEquals( $init['amount'], $authorizeOnBillingAgreementDetailsArgs['authorization_amount'], 'Did not authorize correct amount' ); $this->assertEquals( $init['currency_code'], $authorizeOnBillingAgreementDetailsArgs['currency_code'], 'Did not authorize correct currency code' ); - $queued = $gateway->queue_messages; - $this->assertNotEmpty( $queued['complete'], 'Not sending a message to the complete queue' ); - $message = $queued['complete'][0]; + $message = DonationQueue::instance()->pop( 'complete' ); + $this->assertNotNull( $message, 'Not sending a message to the complete queue' ); $this->assertEquals( 'S01-5318994-6362993-C004044', $message['gateway_txn_id'], 'Queue message has wrong txn ID' ); $this->assertEquals( $init['subscr_id'], $message['subscr_id'], 'Queue message has wrong subscription ID' ); } diff --git a/tests/phpunit/DonationInterfaceTestCase.php b/tests/phpunit/DonationInterfaceTestCase.php index 9a33ce1..481d4c4 100644 --- a/tests/phpunit/DonationInterfaceTestCase.php +++ b/tests/phpunit/DonationInterfaceTestCase.php @@ -71,11 +71,18 @@ // SmashPig core logger. $this->testLogger = new TestingDonationLogger(); DonationLoggerFactory::$overrideLogger = $this->testLogger; + $this->setMwGlobals( array( + 'wgDonationInterfaceEnableQueue' => true, + 'wgDonationInterfaceDefaultQueueServer' => array( + 'type' => 'TestingQueue', + ), + ) ); parent::setUp(); } protected function tearDown() { $this->resetAllEnv(); + TestingQueue::clearAll(); DonationLoggerFactory::$overrideLogger = null; parent::tearDown(); } diff --git a/tests/phpunit/DonationQueueTest.php b/tests/phpunit/DonationQueueTest.php index e934139..0699544 100644 --- a/tests/phpunit/DonationQueueTest.php +++ b/tests/phpunit/DonationQueueTest.php @@ -34,10 +34,6 @@ $this->queue_name = 'test-' . mt_rand(); $this->setMwGlobals( array( - 'wgDonationInterfaceEnableQueue' => true, - 'wgDonationInterfaceDefaultQueueServer' => array( - 'type' => 'TestingQueue', - ), 'wgDonationInterfaceQueues' => array( $this->queue_name => array(), ), @@ -101,13 +97,6 @@ 'source_type' => 'payments', 'source_version' => DonationQueue::getVersionStamp(), ); - } - - public function tearDown() { - // Clear static variables. - TestingQueue::clearAll(); - - parent::tearDown(); } public function testPushMessage() { diff --git a/tests/phpunit/TestConfiguration.php b/tests/phpunit/TestConfiguration.php index f86f1ea..51a21fe 100644 --- a/tests/phpunit/TestConfiguration.php +++ b/tests/phpunit/TestConfiguration.php @@ -159,10 +159,7 @@ $wgMinFraudTimeout = 1; $wgDonationInterfaceMinFraudServers = array( "minfraud.wikimedia.org" ); -// Don't connect to the queue. -$wgDonationInterfaceEnableQueue = false; - -// still can't quite handle mindfraud by itself yet, so default like this. +// still can't quite handle minfraud by itself yet, so default like this. // I will turn it on for individual tests in which I want to verify that it at // least fails closed when enabled. $wgDonationInterfaceEnableMinfraud = false; diff --git a/tests/phpunit/includes/test_gateway/TestingAmazonAdapter.php b/tests/phpunit/includes/test_gateway/TestingAmazonAdapter.php index 45407ea..a1bf0f6 100644 --- a/tests/phpunit/includes/test_gateway/TestingAmazonAdapter.php +++ b/tests/phpunit/includes/test_gateway/TestingAmazonAdapter.php @@ -8,8 +8,6 @@ public static $fakeGlobals = array(); public static $mockClient; - public $queue_messages = array(); - public static function getGlobal( $name ) { if ( array_key_exists( $name, TestingAmazonAdapter::$fakeGlobals ) ) { return TestingAmazonAdapter::$fakeGlobals[$name]; @@ -19,9 +17,5 @@ protected function getPwaClient() { return self::$mockClient; - } - - protected function pushMessage( $queue ) { - $this->queue_messages[$queue][] = $this->getStompTransaction(); } } -- To view, visit https://gerrit.wikimedia.org/r/316500 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I948ef7e3c02f35563bf1868a003fe3c838de4f29 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master 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: Ssmith <ssm...@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