XenoRyet has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/355569 )

Change subject: Merge branch 'master' into deployment
......................................................................

Merge branch 'master' into deployment

0715cc0 Audit processors can read normalized fields in logs
a23b082 Unique-ify invoice ID for recurring
c974314 Payments-init consumer can handle 'currency' message field.

Change-Id: I694d02c19ea58a6e56d96fe000c4d7cfe4c7d2b0
---
D sites/all/modules/queue2civicrm/tests/data/payments-init.json
D sites/all/modules/queue2civicrm/tests/phpunit/PaymentsInitQueueTest.php
D sites/all/modules/wmf_audit/tests/AdyenAuditTest.php
D 
sites/all/modules/wmf_audit/tests/data/Adyen/donation_new/settlement_detail_report_batch_2.csv
D sites/all/modules/wmf_audit/tests/data/logs/payments-adyen-20170218.gz
5 files changed, 0 insertions(+), 350 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/69/355569/1

diff --git a/sites/all/modules/queue2civicrm/tests/data/payments-init.json 
b/sites/all/modules/queue2civicrm/tests/data/payments-init.json
deleted file mode 100644
index 7ddcc1b..0000000
--- a/sites/all/modules/queue2civicrm/tests/data/payments-init.json
+++ /dev/null
@@ -1,18 +0,0 @@
-<<<<<<< HEAD   (9b7a74 Merge branch 'master' into deployment)
-=======
-{
-       "contribution_tracking_id": "12345",
-       "gateway": "testgateway",
-       "order_id": "",
-       "gateway_txn_id": "",
-       "validation_action": "process",
-       "payments_final_status": "complete",
-       "payment_method": "paypal",
-       "payment_submethod": "",
-       "country": "IT",
-       "amount": "2.00",
-       "currency": "EUR",
-       "server": "testpayments1002",
-       "date": "1445990999"
-}
->>>>>>> BRANCH (c97431 Payments-init consumer can handle 'currency' message 
field.)
diff --git 
a/sites/all/modules/queue2civicrm/tests/phpunit/PaymentsInitQueueTest.php 
b/sites/all/modules/queue2civicrm/tests/phpunit/PaymentsInitQueueTest.php
deleted file mode 100644
index c727d87..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/PaymentsInitQueueTest.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<<<<<<< HEAD   (9b7a74 Merge branch 'master' into deployment)
-=======
-<?php
-use queue2civicrm\fredge\PaymentsInitQueueConsumer;
-use SmashPig\Core\Context;
-use SmashPig\Core\QueueConsumers\BaseQueueConsumer;
-
-/**
- * @group Queue2Civicrm
- */
-class PaymentsInitQueueTest extends BaseWmfDrupalPhpUnitTestCase {
-
-       /**
-        * @var PaymentsInitQueueConsumer
-        */
-       protected $consumer;
-
-       public function setUp() {
-               parent::setUp();
-               $config = TestingSmashPigDbQueueConfiguration::instance();
-               Context::initWithLogger( $config );
-               $queue = BaseQueueConsumer::getQueue( 'test' );
-               $queue->createTable( 'test' );
-               $this->consumer = new PaymentsInitQueueConsumer(
-                       'test'
-               );
-       }
-
-       public function testValidMessage() {
-               $message = $this->getMessage();
-               $this->consumer->processMessage( $message );
-
-               $this->compareMessageWithDb( $message );
-       }
-
-       /**
-        * The first message for a ct_id / order_id pair needs to be complete
-        *
-        * @expectedException FredgeDataValidationException
-        */
-       public function testIncompleteMessage() {
-               $message = $this->getMessage();
-               unset( $message['payment_method'] );
-               $this->consumer->processMessage( $message );
-       }
-
-       /**
-        * After one complete message has been inserted, a second message
-        * with the same ct_id / order_id can update only selected fields
-        */
-       public function testUpdatedMessage() {
-               $message1 = $this->getMessage();
-               $message2 = $this->getMessage();
-               $message2['contribution_tracking_id'] = 
$message1['contribution_tracking_id'];
-               $message2['order_id'] = $message1['order_id'];
-
-               $message1['payments_final_status'] = 'pending';
-               $message2['payments_final_status'] = 'pending';
-               unset( $message2['payment_method'] );
-
-               $this->consumer->processMessage( $message1 );
-               $this->compareMessageWithDb( $message1 );
-
-               $this->consumer->processMessage( $message2 );
-               $updated = array_merge(
-                       $message1, $message2
-               );
-               $this->compareMessageWithDb( $updated );
-       }
-
-       protected function compareMessageWithDb( $message ) {
-               $dbEntries = $this->getDbEntries(
-                       $message['contribution_tracking_id'], 
$message['order_id']
-               );
-               $this->assertEquals( 1, count( $dbEntries ) );
-               $fields = array(
-                       'gateway',  'gateway_txn_id', 'validation_action',
-                       'payments_final_status', 'payment_method', 
'payment_submethod',
-                       'country', 'amount', 'server'
-               );
-               foreach ( $fields as $field ) {
-                       $this->assertEquals( $message[$field], 
$dbEntries[0][$field] );
-               }
-               $this->assertEquals( $message['currency'], 
$dbEntries[0]['currency_code'] );
-               $this->assertEquals(
-                       $message['date'], wmf_common_date_civicrm_to_unix( 
$dbEntries[0]['date'] )
-               );
-       }
-
-       protected function getDbEntries( $ctId, $orderId ) {
-               return Database::getConnection( 'default', 'fredge' )
-                       ->select( 'payments_initial', 'f' )
-                       ->fields( 'f', array(
-                               'contribution_tracking_id', 'gateway', 
'order_id',
-                               'gateway_txn_id', 'validation_action', 
'payments_final_status',
-                               'payment_method', 'payment_submethod', 
'country', 'amount',
-                               'currency_code', 'server', 'date'
-                       ) )
-                       ->condition( 'contribution_tracking_id', $ctId )
-                       ->condition( 'order_id', $orderId )
-                       ->execute()
-                       ->fetchAll( PDO::FETCH_ASSOC );
-       }
-
-       /**
-        * @return array
-        */
-       protected function getMessage() {
-               $message = json_decode(
-                       file_get_contents( __DIR__ . 
'/../data/payments-init.json' ),
-                       true
-               );
-               $ctId = mt_rand();
-               $oId = $ctId . '.0';
-               $message['contribution_tracking_id'] = $ctId;
-               $message['order_id'] = $oId;
-               return $message;
-       }
-}
->>>>>>> BRANCH (c97431 Payments-init consumer can handle 'currency' message 
field.)
diff --git a/sites/all/modules/wmf_audit/tests/AdyenAuditTest.php 
b/sites/all/modules/wmf_audit/tests/AdyenAuditTest.php
deleted file mode 100644
index 1ba72c8..0000000
--- a/sites/all/modules/wmf_audit/tests/AdyenAuditTest.php
+++ /dev/null
@@ -1,209 +0,0 @@
-<<<<<<< HEAD   (9b7a74 Merge branch 'master' into deployment)
-=======
-<?php
-
-/**
- * @group Adyen
- * @group WmfAudit
- */
-class AdyenAuditTest extends BaseWmfDrupalPhpUnitTestCase {
-       static protected $messages;
-
-       protected $contact_id;
-       protected $contribution_ids = array();
-
-       public function setUp() {
-               parent::setUp();
-               self::$messages = array();
-
-               $dirs = array(
-                       'wmf_audit_log_archive_dir' => __DIR__ . '/data/logs/',
-                       'adyen_audit_recon_completed_dir' => 
$this->getTempDir(),
-                       'adyen_audit_working_log_dir' => $this->getTempDir(),
-               );
-
-               foreach ( $dirs as $var => $dir ) {
-                       if ( !is_dir( $dir ) ) {
-                               mkdir( $dir );
-                       }
-                       variable_set( $var, $dir );
-               }
-
-               $old_working = glob( $dirs['adyen_audit_working_log_dir'] . '*' 
);
-               foreach ( $old_working as $zap ) {
-                       if ( is_file( $zap ) ) {
-                               unlink( $zap );
-                       }
-               }
-
-               variable_set( 'adyen_audit_log_search_past_days', 7 );
-
-               // Fakedb doesn't fake the original txn for refunds, so add one 
here
-               $existing = wmf_civicrm_get_contributions_from_gateway_id( 
'adyen', '4522268860022701' );
-               if ( $existing ) {
-                       // Previous test run may have crashed before cleaning up
-                       $contribution = $existing[0];
-               } else {
-                       $msg = array(
-                               'contribution_tracking_id' => 92598312,
-                               'currency' => 'USD',
-                               'date' => 1455825706,
-                               'email' => 'a...@asdf.com',
-                               'gateway' => 'adyen',
-                               'gateway_txn_id' => '4522268860022701',
-                               'gross' => 1.00,
-                               'payment_method' => 'cc',
-                       );
-                       $contribution = 
wmf_civicrm_contribution_message_import( $msg );
-               }
-               $this->contact_id = $contribution['contact_id'];
-               $this->contribution_ids[] = $contribution['id'];
-
-               // and another for the chargeback
-               $existing = wmf_civicrm_get_contributions_from_gateway_id( 
'adyen', '4555568860022701' );
-               if ( $existing ) {
-                       // Previous test run may have crashed before cleaning up
-                       $contribution = $existing[0];
-               } else {
-                       $msg = array(
-                               'contribution_tracking_id' => 92598318,
-                               'currency' => 'USD',
-                               'date' => 1443724034,
-                               'email' => 'a...@asdf.org',
-                               'gateway' => 'adyen',
-                               'gateway_txn_id' => '4555568860022701',
-                               'gross' => 1.00,
-                               'payment_method' => 'cc',
-                       );
-                       $contribution = 
wmf_civicrm_contribution_message_import( $msg );
-               }
-               $this->contact_id = $contribution['contact_id'];
-               $this->contribution_ids[] = $contribution['id'];
-       }
-
-       public function tearDown() {
-               foreach( $this->contribution_ids as $id ) {
-      $this->callAPISuccess('Contribution', 'delete', array('id' => $id));
-               }
-
-    $this->callAPISuccess('Contact', 'delete', array('id' => 
$this->contact_id));
-               parent::tearDown();
-       }
-
-       public function auditTestProvider() {
-               return array(
-                       array( __DIR__ . '/data/Adyen/donation/', array(
-                               'main' => array(
-                                       array(
-                                               'contribution_tracking_id' => 
'33992337',
-                                               'country' => 'US',
-                                               'currency' => 'USD',
-                                               'date' => 1455862251,
-                                               'email' => 'a...@asdf.com',
-                                               'fee' => '0.24',
-                                               'first_name' => 'asdf',
-                                               'gateway' => 'adyen',
-                                               'gateway_account' => 
'TestMerchant',
-                                               'gateway_txn_id' => 
'5364893193133131',
-                                               'gross' => '1.00',
-                                               'language' => 'en',
-                                               'last_name' => 'asdff',
-                                               'order_id' => '33992337.0',
-                                               'payment_method' => 'cc',
-                                               'payment_submethod' => 'visa',
-                                               'user_ip' => '77.177.177.77',
-                                               'utm_campaign' => 
'C13_en.wikipedia.org',
-                                               'utm_medium' => 'sidebar',
-                                               'utm_source' => '..cc',
-                                               'settled_gross' => '0.76',
-                                               'settled_currency' => 'USD',
-                                               'settled_fee' => '0.24',
-                                       ),
-                               ),
-                       ) ),
-                       array( __DIR__ . '/data/Adyen/donation_new/', array(
-                               'main' => array(
-                                       array(
-                                               'contribution_tracking_id' => 
'43992337',
-                                               'country' => 'US',
-                                               'currency' => 'USD',
-                                               'date' => 1487484651,
-                                               'email' => 'a...@asdf.com',
-                                               'fee' => '0.24',
-                                               'first_name' => 'asdf',
-                                               'gateway' => 'adyen',
-                                               'gateway_account' => 
'TestMerchant',
-                                               'gateway_txn_id' => 
'5364893193133131',
-                                               'gross' => '1.00',
-                                               'language' => 'en',
-                                               'last_name' => 'asdff',
-                                               'order_id' => '43992337.0',
-                                               'payment_method' => 'cc',
-                                               'payment_submethod' => 'visa',
-                                               'user_ip' => '77.177.177.77',
-                                               'utm_campaign' => 
'C13_en.wikipedia.org',
-                                               'utm_medium' => 'sidebar',
-                                               'utm_source' => '..cc',
-                                               'settled_gross' => '0.76',
-                                               'settled_currency' => 'USD',
-                                               'settled_fee' => '0.24',
-                                       ),
-                               ),
-                       ) ),
-                array( __DIR__ . '/data/Adyen/refund/', array(
-                               'negative' => array(
-                                       array(
-                                               'date' => 1455128736,
-                                               'gateway' => 'adyen',
-                                               'gateway_parent_id' => 
'4522268860022701',
-                                               'gateway_refund_id' => 
'4522268869855336',
-                                               'gross' => '1.00',
-                                               'gross_currency' => 'USD',
-                                               'type' => 'refund',
-                                       ),
-                               ),
-                       ) ),
-                array( __DIR__ . '/data/Adyen/chargeback/', array(
-                               'negative' => array(
-                                       array(
-                                               'date' => 1455128736,
-                                               'gateway' => 'adyen',
-                                               'gateway_parent_id' => 
'4555568860022701',
-                                               'gateway_refund_id' => 
'4555568869855336',
-                                               'gross' => '1.00',
-                                               'gross_currency' => 'USD',
-                                               'type' => 'chargeback',
-                                       ),
-                               ),
-                       ) ),
-               );
-       }
-
-       /**
-        * @dataProvider auditTestProvider
-        */
-       public function testParseFiles( $path, $expectedMessages ) {
-               variable_set( 'adyen_audit_recon_files_dir', $path );
-
-               $this->runAuditor();
-
-               $this->assertEquals( $expectedMessages, self::$messages );
-       }
-
-       protected function runAuditor() {
-               $options = array(
-                       'fakedb' => true,
-                       'quiet' => true,
-                       'test' => true,
-                       'test_callback' => array( 'AdyenAuditTest', 
'receiveMessages' ),
-                       #'verbose' => 'true', # Uncomment to debug.
-               );
-               $audit = new AdyenAuditProcessor( $options );
-               $audit->run();
-       }
-
-       static public function receiveMessages( $msg, $type ) {
-               self::$messages[$type][] = $msg;
-       }
-}
->>>>>>> BRANCH (c97431 Payments-init consumer can handle 'currency' message 
field.)
diff --git 
a/sites/all/modules/wmf_audit/tests/data/Adyen/donation_new/settlement_detail_report_batch_2.csv
 
b/sites/all/modules/wmf_audit/tests/data/Adyen/donation_new/settlement_detail_report_batch_2.csv
deleted file mode 100644
index 9e27c2a..0000000
--- 
a/sites/all/modules/wmf_audit/tests/data/Adyen/donation_new/settlement_detail_report_batch_2.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-Company Account,Merchant Account,Psp Reference,Merchant Reference,Payment 
Method,Creation Date,TimeZone,Type,Modification Reference,Gross Currency,Gross 
Debit (GC),Gross Credit (GC),Exchange Rate,Net Currency,Net Debit (NC),Net 
Credit (NC),Commission (NC),Markup (NC),Scheme Fees (NC),Interchange 
(NC),Payment Method Variant,Modification Merchant Reference,Batch 
Number,Reserved4,Reserved5,Reserved6,Reserved7,Reserved8,Reserved9,Reserved10
-Wikimedia,WikimediaCOM,5364893193133131,43992337.0,visa,2017-02-18 
22:10:51,PST,Settled,5364893193133131,USD,,1.00,1,USD,,0.76,,,0.02,0.22,visadebit,,2,,,,,,,
-Wikimedia,WikimediaCOM,,,,2017-02-18 
23:53:26,PST,MerchantPayout,"TX2342222277XT batch 2, WikimediaCOM batch 2, 
WikimediaCOM",EUR,,,,USD,0.76,,,,,,,,2,,,,,,,
diff --git 
a/sites/all/modules/wmf_audit/tests/data/logs/payments-adyen-20170218.gz 
b/sites/all/modules/wmf_audit/tests/data/logs/payments-adyen-20170218.gz
deleted file mode 100644
index fa976d1..0000000
--- a/sites/all/modules/wmf_audit/tests/data/logs/payments-adyen-20170218.gz
+++ /dev/null
Binary files differ

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I694d02c19ea58a6e56d96fe000c4d7cfe4c7d2b0
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: deployment
Gerrit-Owner: XenoRyet <dkozlow...@wikimedia.org>

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

Reply via email to