Cdentinger has uploaded a new change for review.

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

Change subject: Test PayPal verified message transform
......................................................................

Test PayPal verified message transform

This will probably need to change depending on what an actually valid
message looks like

Change-Id: I67f5a3fbea48a04cdf910fc317d750b3d9c142e0
---
A PaymentProviders/PayPal/Tests/Data/web_accept.transformed.json
M PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
2 files changed, 36 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig 
refs/changes/74/311874/1

diff --git a/PaymentProviders/PayPal/Tests/Data/web_accept.transformed.json 
b/PaymentProviders/PayPal/Tests/Data/web_accept.transformed.json
new file mode 100644
index 0000000..780cc22
--- /dev/null
+++ b/PaymentProviders/PayPal/Tests/Data/web_accept.transformed.json
@@ -0,0 +1,21 @@
+{
+    "correlationId": "",
+    "date": 1471069727,
+    "txn_type": "web_accept",
+    "payment_status": "Completed",
+    "gateway_refund_id": "JJJJJJJJJJJJJJJJJ",
+    "gross_currency": "USD",
+    "contribution_tracking_id": "33333333",
+    "email": "no...@example.com",
+    "first_name": "thanks",
+    "last_name": "bobby",
+    "supplemental_address_1": "hell no",
+    "city_2": "Zurich",
+    "state_province_2": "",
+    "country_2": "CH",
+    "postal_code_2": "8032",
+    "supplemental_address_2": "where indeed",
+    "gross": "7.00",
+    "fee": "0.44",
+    "gateway": "paypal"
+}
diff --git 
a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php 
b/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
index 740acdf..e04d02d 100644
--- a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
+++ b/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php
@@ -22,6 +22,7 @@
         */
        public $config;
        static $verified_msg;
+       static $transformed_msg;
 
        public function setUp() {
                parent::setUp();
@@ -31,18 +32,19 @@
                        file_get_contents( __DIR__ . '/../Data/web_accept.json' 
),
                        true
                );
-       }
-
-       private function capture ( $msg ) {
-               $request = new Request( $msg );
-               $response = new Response;
-               $listener = new Listener;
-               $listener->execute( $request, $response );
+               self::$transformed_msg = json_decode(
+                       file_get_contents(
+                               __DIR__ . 
'/../Data/web_accept.transformed.json' ),
+                       true
+               );
        }
 
        public function testCapture() {
 
-               $this->capture( self::$verified_msg );
+               $request = new Request( self::$verified_msg );
+               $response = new Response;
+               $listener = new Listener;
+               $listener->execute( $request, $response );
 
                // TODO why get it from BaseQueueConsumer instead of config?
                $jobQueue = BaseQueueConsumer::getQueue( 'jobs-paypal' );
@@ -57,15 +59,12 @@
 
        public function testConsume () {
 
-               $this->capture( self::$verified_msg );
-
-               // TODO DRY?
-               $jobQueue = BaseQueueConsumer::getQueue( 'jobs-paypal' );
-               $jobMessage = $jobQueue->pop();
+               $msg = array();
+               $msg['payload'] = self::$verified_msg;
 
                $job = KeyedOpaqueStorableObject::fromJsonProxy(
-                       $jobMessage['php-message-class'],
-                       json_encode( $jobMessage )
+                       'SmashPig\PaymentProviders\PayPal\Job',
+                       json_encode( $msg )
                );
 
                $job->execute();
@@ -73,7 +72,7 @@
                $verifiedQueue = $this->config->object( 'data-store/verified' );
                $verifiedMessage = $verifiedQueue->pop();
 
-               $this->assertNotEmpty( $verifiedMessage );
+               $this->assertEquals( $verifiedMessage, self::$transformed_msg );
 
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I67f5a3fbea48a04cdf910fc317d750b3d9c142e0
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Cdentinger <cdentin...@wikimedia.org>

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

Reply via email to