jenkins-bot has submitted this change and it was merged.

Change subject: Fix subscr_cancel error
......................................................................


Fix subscr_cancel error

Also fix the way the test loops over the different transactions. It's
pretty pathetic that it didn't occur to me that I was just overwriting
keys and not testing duplicates ¯\_(ツ)_/¯

Change-Id: I927127e59ff86a9dfac0e58065acf8c170e073dd
---
M PaymentProviders/PayPal/Job.php
M PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
2 files changed, 21 insertions(+), 18 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/PaymentProviders/PayPal/Job.php b/PaymentProviders/PayPal/Job.php
index bafbd2d..18901bd 100644
--- a/PaymentProviders/PayPal/Job.php
+++ b/PaymentProviders/PayPal/Job.php
@@ -100,7 +100,7 @@
                        ->push( $new_msg );
 
                // FIXME random document formats
-               if ( $txn_type === 'subscr_signup' ) {
+               if ( substr( $txn_type, 0, 7 ) === 'subscr_' ) {
                        $log_id = "subscr_id:{$request['subscr_id']}";
                } else {
                        $log_id = "txn_id:{$request['txn_id']}";
diff --git 
a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php 
b/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
index ae2cbac..1f7904a 100644
--- a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
+++ b/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
@@ -24,11 +24,12 @@
 
        static $fail_verification = false;
 
-       static $message_locations = array(
-               'verified' => 'web_accept.json',
-               'recurring' => 'subscr_signup.json',
-               'recurring' => 'subscr_payment.json',
-               'refund' => 'refund.json',
+       // filename and the queue it should get dropped in
+       static $message_data = array(
+               'web_accept.json' => 'verified',
+               'subscr_signup.json' => 'recurring',
+               'subscr_payment.json' => 'recurring',
+               'refund.json' => 'refund'
        );
 
        static $messages = array();
@@ -42,10 +43,13 @@
                        ->createTable( 'jobs-paypal' );
 
                Context::initWithLogger( $this->config );
-               foreach ( self::$message_locations as $type => $file ) {
-                       self::$messages[$type] = json_decode(
-                               file_get_contents( __DIR__ . '/../Data/' . 
$file ),
-                               true
+               foreach ( self::$message_data as $file => $type ) {
+                       self::$messages[] = array(
+                               'type' => $type,
+                               'payload' => json_decode(
+                                       file_get_contents( __DIR__ . 
'/../Data/' . $file ),
+                                       true
+                               )
                        );
                }
        }
@@ -58,9 +62,9 @@
        }
 
        public function testCapture() {
-               foreach ( self::$messages as $type => $msg ) {
+               foreach ( self::$messages as $msg ) {
 
-                       $this->capture( $msg );
+                       $this->capture( $msg['payload'] );
 
                        $jobQueue = $this->config->object( 
'data-store/jobs-paypal' );
                        $jobMessage = $jobQueue->pop();
@@ -68,8 +72,7 @@
                        $this->assertEquals( $jobMessage['php-message-class'],
                                'SmashPig\PaymentProviders\PayPal\Job' );
 
-                       $this->assertEquals( $jobMessage['payload'], $msg );
-
+                       $this->assertEquals( $jobMessage['payload'], 
$msg['payload'] );
                }
        }
 
@@ -80,8 +83,8 @@
        }
 
        public function testConsume() {
-               foreach ( self::$messages as $type => $msg ) {
-                       $this->capture( $msg );
+               foreach ( self::$messages as $msg ) {
+                       $this->capture( $msg['payload'] );
 
                        $jobQueue = $this->config->object( 
'data-store/jobs-paypal' );
                        $jobMessage = $jobQueue->pop();
@@ -93,8 +96,8 @@
 
                        $job->execute();
 
-                       $queue = $this->config->object( 'data-store/' . $type );
-                       $queue->createTable( $type );
+                       $queue = $this->config->object( 'data-store/' . 
$msg['type'] );
+                       $queue->createTable( $msg['type'] );
                        $message = $queue->pop();
 
                        $this->assertNotEmpty( $message );

-- 
To view, visit https://gerrit.wikimedia.org/r/315613
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I927127e59ff86a9dfac0e58065acf8c170e073dd
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Cdentinger <cdentin...@wikimedia.org>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to