Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316500

Change subject: WIP test queue stuff with PDO/sqlite
......................................................................

WIP test queue stuff with PDO/sqlite

Less fakery in the test adapters, more accurately testing what
actually will go out over the wire.

Depends on php-queue fix I1d272377b5142785ab17a91d7664d1212

Change-Id: I948ef7e3c02f35563bf1868a003fe3c838de4f29
---
M DonationInterface.class.php
M tests/phpunit/Adapter/Amazon/AmazonTest.php
M tests/phpunit/DonationInterfaceTestCase.php
M tests/phpunit/TestConfiguration.php
M tests/phpunit/includes/test_gateway/TestingAmazonAdapter.php
5 files changed, 14 insertions(+), 17 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/00/316500/1

diff --git a/DonationInterface.class.php b/DonationInterface.class.php
index 6cdcf1d..026440e 100644
--- a/DonationInterface.class.php
+++ b/DonationInterface.class.php
@@ -47,7 +47,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 19cfcb4..164f97b 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_reference_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 1d26801..e3f5644 100644
--- a/tests/phpunit/DonationInterfaceTestCase.php
+++ b/tests/phpunit/DonationInterfaceTestCase.php
@@ -71,6 +71,14 @@
                // SmashPig core logger.
                $this->testLogger = new TestingDonationLogger();
                DonationLoggerFactory::$overrideLogger = $this->testLogger;
+               $this->setMwGlobals( array(
+                       'wgDonationInterfaceEnableQueue' => true,
+                       'wgDonationInterfaceDefaultQueueServer' => array(
+                               'type' => 'PHPQueue\Backend\PDO',
+                               'connection_string' => 'sqlite::memory:',
+                               'pdo_options' => array( PDO::ATTR_PERSISTENT => 
true )
+                       ),
+               ) );
                parent::setUp();
        }
 
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: newchange
Gerrit-Change-Id: I948ef7e3c02f35563bf1868a003fe3c838de4f29
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to