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

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

Merge branch 'master' into deployment

And update vendor submodule

8c89e7bf9 Add tests & finalise unsubscribe process
edefb82ab Update SmashPig and DonationInterface
a2bf76aa4 Fix typo causing enotice & suppressed not to populate

Change-Id: I3190ba4a900e178865a2c443a6f64a7ef2c852ec
---
D sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
D sites/all/modules/queue2civicrm/tests/phpunit/BannerHistoryTest.php
D sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
D sites/all/modules/queue2civicrm/tests/phpunit/PaymentsInitQueueTest.php
D sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
D sites/all/modules/queue2civicrm/tests/phpunit/RefundQueueTest.php
D sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
D sites/all/modules/wmf_audit/tests/AmazonAuditTest.php
D sites/all/modules/wmf_civicrm/tests/phpunit/DonationInterfaceFactoryTest.php
D sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
M vendor
11 files changed, 1 insertion(+), 1,590 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/44/367944/1

diff --git 
a/sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php 
b/sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
deleted file mode 100644
index d376c2f..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-use queue2civicrm\fredge\AntifraudQueueConsumer;
-
-/**
- * @group Queue2Civicrm
- */
-class AntifraudQueueTest extends BaseWmfDrupalPhpUnitTestCase {
-
-       /**
-        * @var AntifraudQueueConsumer
-        */
-       protected $consumer;
-
-       public function setUp() {
-               parent::setUp();
-               $this->consumer = new AntifraudQueueConsumer(
-                       'payments-antifraud'
-               );
-       }
-
-       public function testValidMessage() {
-               $message = json_decode(
-                       file_get_contents( __DIR__ . 
'/../data/payments-antifraud.json'),
-                       true
-               );
-               $ctId = mt_rand();
-               $oId = $ctId . '.0';
-               $message['contribution_tracking_id'] = $ctId;
-               $message['order_id'] = $oId;
-               $this->consumer->processMessage( $message );
-
-               $this->compareMessageWithDb( $message, 
$message['score_breakdown'] );
-       }
-
-       /**
-        * The first message for a ct_id / order_id pair needs to be complete
-        *
-        * @expectedException FredgeDataValidationException
-        */
-       public function testIncompleteMessage() {
-               $message = json_decode(
-                       file_get_contents( __DIR__ . 
'/../data/payments-antifraud.json'),
-                       true
-               );
-               unset( $message['user_ip'] );
-               $this->consumer->processMessage( $message );
-       }
-
-       public function testCombinedMessage() {
-               $message1 = json_decode(
-                       file_get_contents( __DIR__ . 
'/../data/payments-antifraud.json'),
-                       true
-               );
-               $message2 = json_decode(
-                       file_get_contents( __DIR__ . 
'/../data/payments-antifraud.json'),
-                       true
-               );
-               $ctId = mt_rand();
-               $oId = $ctId . '.0';
-               $message1['contribution_tracking_id'] = $ctId;
-               $message2['contribution_tracking_id'] = $ctId;
-               $message1['order_id'] = $oId;
-               $message2['order_id'] = $oId;
-               $message1['score_breakdown'] = array_slice(
-                       $message1['score_breakdown'], 0, 4
-               );
-               $message2['score_breakdown'] = array_slice(
-                       $message2['score_breakdown'], 4, 4
-               );
-               $this->consumer->processMessage( $message1 );
-
-               $dbEntries = $this->getDbEntries( $ctId, $oId );
-               $this->assertEquals( 4, count( $dbEntries ) );
-
-               $this->consumer->processMessage( $message2 );
-
-               $breakdown = array_merge(
-                       $message1['score_breakdown'], 
$message2['score_breakdown']
-               );
-
-               $this->compareMessageWithDb( $message1, $breakdown );
-       }
-
-       protected function compareMessageWithDb( $common, $breakdown ) {
-               $dbEntries = $this->getDbEntries(
-                       $common['contribution_tracking_id'], $common['order_id']
-               );
-               $this->assertEquals( 8, count( $dbEntries ) );
-               $fields = array(
-                       'gateway',  'validation_action', 'payment_method',
-                       'risk_score', 'server'
-               );
-               foreach ( $fields as $field ) {
-                       $this->assertEquals( $common[$field], 
$dbEntries[0][$field] );
-               }
-               $this->assertEquals( ip2long( $common['user_ip'] ), 
$dbEntries[0]['user_ip'] );
-               $this->assertEquals(
-                       $common['date'], wmf_common_date_civicrm_to_unix( 
$dbEntries[0]['date'] )
-               );
-               foreach ( $dbEntries as $score ) {
-                       $name = $score['filter_name'];
-                       $this->assertEquals(
-                               $breakdown[$name], $score['fb_risk_score'], 
"Mismatched $name score"
-                       );
-               }
-       }
-
-       protected function getDbEntries( $ctId, $orderId ) {
-               $query = Database::getConnection( 'default', 'fredge' )
-                       ->select( 'payments_fraud', 'f' );
-               $query->join(
-                       'payments_fraud_breakdown', 'fb', 'fb.payments_fraud_id 
= f.id'
-               );
-               return $query
-                       ->fields( 'f', array(
-                               'contribution_tracking_id', 'gateway', 
'order_id',
-                               'validation_action', 'user_ip', 
'payment_method',
-                               'risk_score', 'server', 'date'
-                       ) )
-                       ->fields( 'fb', array( 'filter_name', 'risk_score' ) )
-                       ->condition( 'contribution_tracking_id', $ctId )
-                       ->condition( 'order_id', $orderId )
-                       ->execute()
-                       ->fetchAll( PDO::FETCH_ASSOC );
-       }
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git 
a/sites/all/modules/queue2civicrm/tests/phpunit/BannerHistoryTest.php 
b/sites/all/modules/queue2civicrm/tests/phpunit/BannerHistoryTest.php
deleted file mode 100644
index f45ca99..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/BannerHistoryTest.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-use queue2civicrm\banner_history\BannerHistoryQueueConsumer;
-
-/**
- * @group Queue2Civicrm
- */
-class BannerHistoryTest extends BaseWmfDrupalPhpUnitTestCase {
-
-       /**
-        * @var BannerHistoryQueueConsumer
-        */
-       protected $consumer;
-
-       public function setUp() {
-               parent::setUp();
-               $this->consumer = new BannerHistoryQueueConsumer(
-                       'test'
-               );
-       }
-
-       public function testValidMessage() {
-               $msg = array(
-                       'banner_history_id' => substr(
-                               md5( mt_rand() . time() ), 0, 16
-                       ),
-                       'contribution_tracking_id' => strval( mt_rand() ),
-               );
-               $this->consumer->processMessage( $msg );
-               // check for thing in db
-       }
-
-       /**
-        * @expectedException WmfException
-        */
-       public function testBadContributionId() {
-               $msg = array(
-                       'banner_history_id' => substr(
-                               md5( mt_rand() . time() ), 0, 16
-                       ),
-                       'contribution_tracking_id' => '1=1; DROP TABLE 
students;--',
-               );
-               $this->consumer->processMessage( $msg );
-       }
-
-       /**
-        * @expectedException WmfException
-        */
-       public function testBadHistoryId() {
-               $msg = array(
-                       'banner_history_id' => '\';GRANT ALL ON drupal.* TO 
\'leet\'@\'haxx0r\'',
-                       'contribution_tracking_id' => strval( mt_rand() ),
-               );
-               $this->consumer->processMessage( $msg );
-       }
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git 
a/sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php 
b/sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
deleted file mode 100644
index cbbc6a6..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
+++ /dev/null
@@ -1,338 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-
-use queue2civicrm\DonationQueueConsumer;
-use SmashPig\Core\Context;
-use SmashPig\Core\DataStores\PendingDatabase;
-
-/**
- * @group Pipeline
- * @group DonationQueue
- * @group Queue2Civicrm
- */
-class DonationQueueTest extends BaseWmfDrupalPhpUnitTestCase {
-       /**
-        * @var PendingDatabase
-        */
-       protected $pendingDb;
-
-       /**
-        * @var DonationQueueConsumer
-        */
-       protected $queueConsumer;
-
-       public function setUp() {
-               parent::setUp();
-               $this->pendingDb = PendingDatabase::get();
-               $this->queueConsumer = new DonationQueueConsumer( 'test' );
-       }
-
-       /**
-        * Process an ordinary (one-time) donation message
-        */
-       public function testDonation() {
-               $message = new TransactionMessage(
-                       array( 'gross' => 400, 'original_gross' => 400, 
'original_currency' => 'USD' )
-               );
-               $message2 = new TransactionMessage();
-
-               exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
-               exchange_rate_cache_set( $message->get( 'currency' ), 
$message->get( 'date' ), 3 );
-
-               $this->queueConsumer->processMessage( $message->getBody() );
-               $this->queueConsumer->processMessage( $message2->getBody() );
-
-               $campaignField = wmf_civicrm_get_custom_field_name( 'campaign' 
);
-
-               $expected = array(
-                       'contact_type' => 'Individual',
-                       'sort_name' => 'laast, firrst',
-                       'display_name' => 'firrst laast',
-                       'first_name' => 'firrst',
-                       'last_name' => 'laast',
-                       'currency' => 'USD',
-                       'total_amount' => '400.00',
-                       'fee_amount' => '0.00',
-                       'net_amount' => '400.00',
-                       'trxn_id' => 'GLOBALCOLLECT ' . 
$message->getGatewayTxnId(),
-                       'contribution_source' => 'USD 400',
-                       'financial_type' => 'Cash',
-                       'contribution_status' => 'Completed',
-                       'payment_instrument' => 'Credit Card: Visa',
-                       'invoice_id' => $message->get('order_id'),
-                       $campaignField => '',
-               );
-               $returnFields = array_keys( $expected );
-
-               $contribution = civicrm_api3(
-                       'Contribution',
-                       'getsingle',
-                       array(
-                               wmf_civicrm_get_custom_field_name( 
'gateway_txn_id' ) => $message->getGatewayTxnId(),
-                               'return' => $returnFields
-                       )
-               );
-
-               $this->assertArraySubset( $expected, $contribution );
-
-               $contribution2 = civicrm_api3(
-                       'Contribution',
-                       'getsingle',
-                       array(
-                               wmf_civicrm_get_custom_field_name( 
'gateway_txn_id' ) => $message2->getGatewayTxnId(),
-                               'return' => $returnFields
-                       )
-               );
-
-               $expected = array(
-                       'contact_type' => 'Individual',
-                       'sort_name' => 'laast, firrst',
-                       'display_name' => 'firrst laast',
-                       'first_name' => 'firrst',
-                       'last_name' => 'laast',
-                       'currency' => 'USD',
-                       'total_amount' => '2857.02',
-                       'fee_amount' => '0.00',
-                       'net_amount' => '2857.02',
-                       'trxn_id' => 'GLOBALCOLLECT ' . 
$message2->getGatewayTxnId(),
-                       'contribution_source' => 'PLN 952.34',
-                       'financial_type' => 'Cash',
-                       'contribution_status' => 'Completed',
-                       'payment_instrument' => 'Credit Card: Visa',
-                       'invoice_id' => $message2->get('order_id'),
-                       $campaignField => 'Benefactor Gift',
-               );
-               $this->assertArraySubset( $expected, $contribution2 );
-               $this->assertNotEquals( $contribution['contact_id'], 
$contribution2['contact_id'] );
-       }
-
-       /**
-        * Process an ordinary (one-time) donation message with an UTF campaign.
-        */
-       public function testDonationWithUTFCampaignOption() {
-               $message = new TransactionMessage( array( 'utm_campaign' => 
'EmailCampaign1' ) );
-               $appealFieldID = $this->createCustomOption( 'Appeal', 
'EmailCampaign1' );
-
-               exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
-               exchange_rate_cache_set( $message->get( 'currency' ), 
$message->get( 'date' ), 3 );
-
-               $this->queueConsumer->processMessage( $message->getBody() );
-
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $message->getGateway(),
-                       $message->getGatewayTxnId()
-               );
-               $contribution = civicrm_api3(
-                       'Contribution',
-                       'getsingle',
-                       array(
-                               'id' => $contributions[0]['id'],
-                               'return' => 'custom_' . $appealFieldID,
-                       )
-               );
-               $this->assertEquals( 'EmailCampaign1', $contribution['custom_' 
. $appealFieldID] );
-               $this->deleteCustomOption( 'Appeal', 'EmailCampaign1' );
-       }
-
-       /**
-        * Process an ordinary (one-time) donation message with an UTF campaign 
not already existing.
-        */
-       public function testDonationWithInvalidUTFCampaignOption() {
-               civicrm_initialize();
-               $optionValue = uniqid();
-               $message = new TransactionMessage( array( 'utm_campaign' => 
$optionValue ) );
-               $appealField = civicrm_api3( 'custom_field', 'getsingle', 
array( 'name' => 'Appeal' ) );
-
-               exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
-               exchange_rate_cache_set( $message->get( 'currency' ), 
$message->get( 'date' ), 3 );
-
-               $this->queueConsumer->processMessage( $message->getBody() );
-
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $message->getGateway(),
-                       $message->getGatewayTxnId()
-               );
-               $contribution = civicrm_api3(
-                       'Contribution',
-                       'getsingle',
-                       array(
-                               'id' => $contributions[0]['id'],
-                               'return' => 'custom_' . $appealField['id'],
-                       )
-               );
-               $this->assertEquals( $optionValue, $contribution['custom_' . 
$appealField['id']] );
-               $this->deleteCustomOption( 'Appeal', $optionValue );
-       }
-
-       /**
-        * Process an ordinary (one-time) donation message with an UTF campaign 
previously disabled.
-        */
-       public function testDonationWithDisabledUTFCampaignOption() {
-               civicrm_initialize();
-               $optionValue = uniqid();
-               $message = new TransactionMessage( array( 'utm_campaign' => 
$optionValue ) );
-               $appealFieldID = $this->createCustomOption( 'Appeal', 
$optionValue, FALSE );
-
-               exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
-               exchange_rate_cache_set( $message->get( 'currency' ), 
$message->get( 'date' ), 3 );
-
-               $this->queueConsumer->processMessage( $message->getBody() );
-
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $message->getGateway(),
-                       $message->getGatewayTxnId()
-               );
-               $contribution = civicrm_api3(
-                       'Contribution',
-                       'getsingle',
-                       array(
-                               'id' => $contributions[0]['id'],
-                               'return' => 'custom_' . $appealFieldID,
-                       )
-               );
-               $this->assertEquals( $optionValue, $contribution['custom_' . 
$appealFieldID] );
-               $this->deleteCustomOption( 'Appeal', $optionValue );
-       }
-
-       /**
-        * Process an ordinary (one-time) donation message with an UTF campaign 
with a different label.
-        */
-       public function testDonationWithDifferentLabelUTFCampaignOption() {
-               civicrm_initialize();
-               $optionValue = uniqid();
-               $message = new TransactionMessage( array( 'utm_campaign' => 
$optionValue ) );
-               $appealFieldID = $this->createCustomOption( 'Appeal', 
$optionValue, TRUE, uniqid() );
-
-               exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
-               exchange_rate_cache_set( $message->get( 'currency' ), 
$message->get( 'date' ), 3 );
-
-               $this->queueConsumer->processMessage( $message->getBody() );
-
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $message->getGateway(),
-                       $message->getGatewayTxnId()
-               );
-               $contribution = civicrm_api3(
-                       'Contribution',
-                       'getsingle',
-                       array(
-                               'id' => $contributions[0]['id'],
-                               'return' => 'custom_' . $appealFieldID,
-                       )
-               );
-               $this->assertEquals( $optionValue, $contribution['custom_' . 
$appealFieldID] );
-               $values = $this->callAPISuccess( 'OptionValue', 'get', array( 
'value' => $optionValue ) );
-               $this->assertEquals( 1, $values['count'] );
-               $this->deleteCustomOption( 'Appeal', $optionValue );
-       }
-
-       /**
-        * Create a custom option for the given field.
-        *
-        * @param string $fieldName
-        *
-        * @param string $optionValue
-        * @param bool $is_active
-        *   Is the option value enabled.
-        *
-        * @return mixed
-        * @throws \CiviCRM_API3_Exception
-        */
-       public function createCustomOption( $fieldName, $optionValue, 
$is_active = 1, $label = NULL ) {
-               if ( !$label ) {
-                       $label = $optionValue;
-               }
-               $appealField = civicrm_api3( 'custom_field', 'getsingle', 
array( 'name' => $fieldName ) );
-               civicrm_api3(
-                       'OptionValue',
-                       'create',
-                       array(
-                               'name' => $label,
-                               'value' => $optionValue,
-                               'option_group_id' => 
$appealField['option_group_id'],
-                               'is_active' => $is_active,
-                       )
-               );
-               wmf_civicrm_flush_cached_options();
-               return $appealField['id'];
-       }
-
-       /**
-        * Cleanup custom field option after test.
-        *
-        * @param string $fieldName
-        *
-        * @param string $optionValue
-        *
-        * @return mixed
-        * @throws \CiviCRM_API3_Exception
-        */
-       public function deleteCustomOption( $fieldName, $optionValue ) {
-               $appealField = civicrm_api3( 'custom_field', 'getsingle', 
array( 'name' => $fieldName ) );
-               return $appealField['id'];
-       }
-
-       /**
-        * Process a donation message with some info from pending db
-        * @dataProvider getSparseMessages
-        * @param TransactionMessage $message
-        * @param array $pendingMessage
-        */
-       public function testDonationSparseMessages( $message, $pendingMessage ) 
{
-               $pendingMessage['order_id'] = $message->get( 'order_id' );
-               $this->pendingDb->storeMessage( $pendingMessage );
-               $appealFieldID = $this->createCustomOption(
-                       'Appeal',
-                       $pendingMessage['utm_campaign'],
-                       false
-               );
-
-               exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
-               exchange_rate_cache_set( $message->get( 'currency' ), 
$message->get( 'date' ), 3 );
-
-               $this->queueConsumer->processMessage( $message->getBody() );
-
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $message->getGateway(),
-                       $message->getGatewayTxnId()
-               );
-               $contribution = civicrm_api3(
-                       'Contribution',
-                       'getsingle',
-                       array(
-                               'id' => $contributions[0]['id'],
-                               'return' => 'custom_' . $appealFieldID,
-                       )
-               );
-               $this->assertEquals( $pendingMessage['utm_campaign'], 
$contribution['custom_' . $appealFieldID] );
-               $this->deleteCustomOption( 'Appeal', 
$pendingMessage['utm_campaign'] );
-               $pendingEntry = $this->pendingDb->fetchMessageByGatewayOrderId(
-                       $message->get( 'gateway' ),
-                       $pendingMessage['order_id']
-               );
-               $this->assertNull( $pendingEntry, 'Should have deleted pending 
DB entry' );
-               civicrm_api3( 'Contribution', 'delete', array( 'id' => 
$contributions[0]['id'] ) );
-               civicrm_api3( 'Contact', 'delete', array( 'id' => 
$contributions[0]['contact_id'] ) );
-       }
-
-       public function getSparseMessages() {
-               return array(
-                       array(
-                               new AmazonDonationMessage(),
-                               json_decode(
-                                       file_get_contents( __DIR__ . 
'/../data/pending_amazon.json' ),
-                                       true
-                               )
-                       ),
-                       array(
-                               new AstroPayDonationMessage(),
-                               json_decode(
-                                       file_get_contents( __DIR__ . 
'/../data/pending_astropay.json' ),
-                                       true
-                               )
-                       ),
-               );
-       }
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
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 3b16d82..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/PaymentsInitQueueTest.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-use queue2civicrm\fredge\PaymentsInitQueueConsumer;
-
-/**
- * @group Queue2Civicrm
- */
-class PaymentsInitQueueTest extends BaseWmfDrupalPhpUnitTestCase {
-
-       /**
-        * @var PaymentsInitQueueConsumer
-        */
-       protected $consumer;
-
-       public function setUp() {
-               parent::setUp();
-               $this->consumer = new PaymentsInitQueueConsumer(
-                       'payments-init'
-               );
-       }
-
-       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 (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git 
a/sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php 
b/sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
deleted file mode 100644
index 7999623..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
+++ /dev/null
@@ -1,250 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-use queue2civicrm\recurring\RecurringQueueConsumer;
-
-/**
- * @group Queue2Civicrm
- */
-class RecurringQueueTest extends BaseWmfDrupalPhpUnitTestCase {
-
-       /**
-        * @var RecurringQueueConsumer
-        */
-       protected $consumer;
-
-       protected $contributions = array();
-       protected $ctIds = array();
-
-       public function setUp() {
-               parent::setUp();
-               $this->consumer = new RecurringQueueConsumer(
-                       'recurring'
-               );
-       }
-
-       // TODO: other queue import tests need to clean up like this!
-       public function tearDown() {
-               foreach ( $this->ctIds as $ctId ) {
-                       db_delete( 'contribution_tracking' )
-                               ->condition( 'id', $ctId )
-                               ->execute();
-               }
-               foreach( $this->contributions as $contribution ) {
-                       if ( !empty( $contribution['contribution_recur_id'] ) ) 
{
-                               CRM_Core_DAO::executeQuery(
-                                       "
-                               DELETE FROM civicrm_contribution_recur
-                               WHERE id = %1",
-                                       array( 1 => array( 
$contribution['contribution_recur_id'], 'Positive' ) )
-                               );
-                       }
-                       CRM_Core_DAO::executeQuery(
-                               "
-                       DELETE FROM civicrm_contribution
-                       WHERE id = %1",
-                               array( 1 => array( $contribution['id'], 
'Positive' ) )
-                       );
-                       CRM_Core_DAO::executeQuery(
-                               "
-                       DELETE FROM civicrm_contact
-                       WHERE id = %1",
-                               array( 1 => array( $contribution['contact_id'], 
'Positive' ) )
-                       );
-               }
-               parent::tearDown();
-       }
-
-       protected function addContributionTracking( $ctId ) {
-               $this->ctIds[] = $ctId;
-               db_insert( 'contribution_tracking' )
-                       ->fields( array( 'id' => $ctId ) )
-                       ->execute();
-       }
-
-       protected function importMessage( TransactionMessage $message ) {
-               $payment_time = $message->get( 'date' );
-               exchange_rate_cache_set( 'USD', $payment_time, 1 );
-               $currency = $message->get( 'currency' );
-               if ( $currency !== 'USD' ) {
-                       exchange_rate_cache_set( $currency, $payment_time, 3 );
-               }
-               $this->consumer->processMessage( $message->getBody() );
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $message->getGateway(),
-                       $message->getGatewayTxnId()
-               );
-               $this->contributions[] = $contributions[0];
-               return $contributions;
-       }
-
-       public function testCreateDistinctContributions() {
-               civicrm_initialize();
-               $subscr_id = mt_rand();
-               $values = $this->processRecurringSignup( $subscr_id );
-
-               $message = new RecurringPaymentMessage( $values );
-               $message2 = new RecurringPaymentMessage( $values );
-
-               $msg = $message->getBody();
-               $this->addContributionTracking( 
$msg['contribution_tracking_id'] );
-
-               $contributions = $this->importMessage( $message );
-               $ctRecord = db_select( 'contribution_tracking', 'ct' )
-                       ->fields( 'ct' )
-                       ->condition( 'id', $msg['contribution_tracking_id'], 
'=' )
-                       ->execute()
-                       ->fetchAssoc();
-
-               $this->assertEquals(
-                       $contributions[0]['id'],
-                       $ctRecord['contribution_id']
-               );
-               $contributions2 = $this->importMessage( $message2 );
-
-               $ctRecord2 = db_select( 'contribution_tracking', 'ct' )
-                       ->fields( 'ct' )
-                       ->condition( 'id', $msg['contribution_tracking_id'], 
'=' )
-                       ->execute()
-                       ->fetchAssoc();
-
-               // The ct_id record should still link to the first contribution
-               $this->assertEquals(
-                       $contributions[0]['id'],
-                       $ctRecord2['contribution_id']
-               );
-               $recur_record = wmf_civicrm_get_recur_record( $subscr_id );
-
-               $this->assertNotEquals( false, $recur_record );
-
-               $this->assertEquals( 1, count( $contributions ) );
-               $this->assertEquals( $recur_record->id, 
$contributions[0]['contribution_recur_id'] );
-               $this->assertEquals( 1, count( $contributions2 ) );
-               $this->assertEquals( $recur_record->id, 
$contributions2[0]['contribution_recur_id'] );
-
-               $this->assertEquals( $contributions[0]['contact_id'], 
$contributions2[0]['contact_id'] );
-               $addresses = $this->callAPISuccess(
-                       'Address',
-                       'get',
-                       array( 'contact_id' => $contributions2[0]['contact_id'] 
)
-               );
-               $this->assertEquals( 1, $addresses['count'] );
-               // The address comes from the recurring_payment.json not the 
recurring_signup.json as it
-               // has been overwritten. This is perhaps not a valid scenario 
in production but it is
-               // the scenario the code works to. In production they would 
probably always be the same.
-               $this->assertEquals( '1211122 132 st', 
$addresses['values'][$addresses['id']]['street_address'] );
-
-               $emails = $this->callAPISuccess( 'Email', 'get', array( 
'contact_id' => $contributions2[0]['contact_id'] ) );
-               $this->assertEquals( 1, $addresses['count'] );
-               $this->assertEquals( 'test...@wikimedia.org', 
$emails['values'][$emails['id']]['email'] );
-       }
-
-       public function testNormalizedMessages() {
-               civicrm_initialize();
-               $subscr_id = mt_rand();
-               $values = $this->processRecurringSignup( $subscr_id );
-
-               $message = new RecurringPaymentMessage( $values );
-
-               $this->addContributionTracking( $message->get( 
'contribution_tracking_id' ) );
-
-               $contributions = $this->importMessage( $message );
-
-               $recur_record = wmf_civicrm_get_recur_record( $subscr_id );
-               $this->assertNotEquals( false, $recur_record );
-
-               $this->assertEquals( 1, count( $contributions ) );
-               $this->assertEquals( $recur_record->id, 
$contributions[0]['contribution_recur_id'] );
-
-               $addresses = $this->callAPISuccess(
-                       'Address',
-                       'get',
-                       array( 'contact_id' => $contributions[0]['contact_id'] )
-               );
-               $this->assertEquals( 1, $addresses['count'] );
-
-               $emails = $this->callAPISuccess( 'Email', 'get', array( 
'contact_id' => $contributions[0]['contact_id'] ) );
-               $this->assertEquals( 1, $addresses['count'] );
-               $this->assertEquals( 'test...@wikimedia.org', 
$emails['values'][$emails['id']]['email'] );
-       }
-
-       /**
-        *  Test that a blank address is not written to the DB.
-        */
-       public function testBlankEmail() {
-               civicrm_initialize();
-               $subscr_id = mt_rand();
-               $values = $this->processRecurringSignup( $subscr_id );
-
-               $message = new RecurringPaymentMessage( $values );
-               $messageBody = $message->getBody();
-
-               $addressFields = array( 'city', 'country', 'state_province', 
'street_address', 'postal_code' );
-               foreach ( $addressFields as $addressField ) {
-                       $messageBody[$addressField] = '';
-               }
-
-               $this->addContributionTracking( 
$messageBody['contribution_tracking_id'] );
-
-               $this->consumer->processMessage( $messageBody );
-
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $message->getGateway(),
-                       $message->getGatewayTxnId()
-               );
-               $this->contributions[] = $contributions[0];
-               $addresses = $this->callAPISuccess(
-                       'Address',
-                       'get',
-                       array( 'contact_id' => $contributions[0]['contact_id'], 
'sequential' => 1 )
-               );
-               $this->assertEquals( 1, $addresses['count'] );
-               // The address created by the sign up (Lockwood Rd) should not 
have been overwritten by the blank.
-               $this->assertEquals( '5109 Lockwood Rd', 
$addresses['values'][0]['street_address'] );
-       }
-
-       /**
-        * @expectedException WmfException
-        * @expectedExceptionCode WmfException::MISSING_PREDECESSOR
-        */
-       public function testMissingPredecessor() {
-               $message = new RecurringPaymentMessage(
-                       array(
-                               'subscr_id' => mt_rand(),
-                       )
-               );
-
-               $this->importMessage( $message );
-       }
-
-       /**
-        * @expectedException WmfException
-        * @expectedExceptionCode WmfException::INVALID_RECURRING
-        */
-       public function testNoSubscrId() {
-               $message = new RecurringPaymentMessage(
-                       array(
-                               'subscr_id' => null,
-                       )
-               );
-
-               $this->importMessage( $message );
-       }
-
-       /**
-        * Process the original recurring sign up message.
-        *
-        * @param string $subscr_id
-        * @return array
-        */
-       private function processRecurringSignup( $subscr_id ) {
-               $values = array( 'subscr_id' => $subscr_id );
-               $signup_message = new RecurringSignupMessage( $values );
-               $subscr_time = $signup_message->get( 'date' );
-               exchange_rate_cache_set( 'USD', $subscr_time, 1 );
-               exchange_rate_cache_set( $signup_message->get( 'currency' ), 
$subscr_time, 2 );
-               $this->consumer->processMessage( $signup_message->getBody() );
-               return $values;
-       }
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git a/sites/all/modules/queue2civicrm/tests/phpunit/RefundQueueTest.php 
b/sites/all/modules/queue2civicrm/tests/phpunit/RefundQueueTest.php
deleted file mode 100644
index cf51d41..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/RefundQueueTest.php
+++ /dev/null
@@ -1,112 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-use queue2civicrm\refund\RefundQueueConsumer;
-
-/**
- * @group Queue2Civicrm
- */
-class RefundQueueTest extends BaseWmfDrupalPhpUnitTestCase {
-
-       /**
-        * @var RefundQueueConsumer
-        */
-       protected $consumer;
-
-       public function setUp() {
-               parent::setUp();
-               $this->consumer = new RefundQueueConsumer(
-                       'refund'
-               );
-       }
-
-       public function testRefund() {
-               $donation_message = new TransactionMessage();
-               $refund_message = new RefundMessage(
-                       array(
-                               'gateway' => $donation_message->getGateway(),
-                               'gateway_parent_id' => 
$donation_message->getGatewayTxnId(),
-                               'gateway_refund_id' => mt_rand(),
-                               'gross' => $donation_message->get( 
'original_gross' ),
-                               'gross_currency' => $donation_message->get( 
'original_currency' ),
-                       )
-               );
-
-               exchange_rate_cache_set( 'USD', $donation_message->get( 'date' 
), 1 );
-               exchange_rate_cache_set( $donation_message->get( 'currency' ), 
$donation_message->get( 'date' ), 3 );
-
-               $message_body = $donation_message->getBody();
-               wmf_civicrm_contribution_message_import( $message_body );
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $donation_message->getGateway(),
-                       $donation_message->getGatewayTxnId()
-               );
-               $this->assertEquals( 1, count( $contributions ) );
-
-               $this->consumer->processMessage( $refund_message->getBody() );
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $refund_message->getGateway(),
-                       $refund_message->getGatewayTxnId()
-               );
-               $this->assertEquals( 1, count( $contributions ) );
-       }
-
-       /**
-        * @expectedException WmfException
-        * @expectedExceptionCode WmfException::MISSING_PREDECESSOR
-        */
-       public function testRefundNoPredecessor() {
-               $refund_message = new RefundMessage();
-
-               $this->consumer->processMessage( $refund_message->getBody() );
-       }
-
-       /**
-        * Test refunding a mismatched amount.
-        *
-        * Note that we were checking against an exception - but it turned out 
the exception
-        * could be thrown in this fn $this->queueConsumer->processMessage if 
the exchange rate does not
-        * exist - which is not what we are testing for.
-        */
-       public function testRefundMismatched() {
-               $this->setExchangeRates( 1234567, array( 'USD' => 1, 'PLN' => 
0.5 ) );
-               $donation_message = new TransactionMessage(
-                       array(
-                               'gateway' => 'test_gateway',
-                               'gateway_txn_id' => mt_rand(),
-                       )
-               );
-               $refund_message = new RefundMessage(
-                       array(
-                               'gateway' => 'test_gateway',
-                               'gateway_parent_id' => 
$donation_message->getGatewayTxnId(),
-                               'gateway_refund_id' => mt_rand(),
-                               'gross' => $donation_message->get( 
'original_gross' ) + 1,
-                               'gross_currency' => $donation_message->get( 
'original_currency' ),
-                       )
-               );
-
-               $message_body = $donation_message->getBody();
-               wmf_civicrm_contribution_message_import( $message_body );
-               $contributions = wmf_civicrm_get_contributions_from_gateway_id(
-                       $donation_message->getGateway(),
-                       $donation_message->getGatewayTxnId()
-               );
-               $this->assertEquals( 1, count( $contributions ) );
-
-               $this->consumer->processMessage( $refund_message->getBody() );
-               $contributions = $this->callAPISuccess(
-                       'Contribution',
-                       'get',
-                       array( 'contact_id' => $contributions[0]['contact_id'], 
'sequential' => 1 )
-               );
-               $this->assertEquals( 2, count( $contributions['values'] ) );
-               $this->assertEquals(
-                       'Chargeback',
-                       CRM_Contribute_PseudoConstant::contributionStatus( 
$contributions['values'][0]['contribution_status_id'] )
-               );
-               $this->assertEquals( '-.5', 
$contributions['values'][1]['total_amount'] );
-       }
-
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git 
a/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
 
b/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
deleted file mode 100644
index fc24a70..0000000
--- 
a/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
+++ /dev/null
@@ -1,210 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-
-/**
- * @group GlobalCollect
- */
-class RecurringGlobalCollectTest extends BaseWmfDrupalPhpUnitTestCase {
-       protected $subscriptionId;
-       protected $amount;
-       protected $contributions;
-       protected $contactId;
-       protected $contributionRecurId;
-
-       function setUp() {
-               parent::setUp();
-               civicrm_initialize();
-
-               // FIXME - but do we really want to stuff the autoloader with 
all of our test classes?
-               require_once( DRUPAL_ROOT . 
'/../vendor/wikimedia/donation-interface/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php'
 );
-               global $wgDonationInterfaceGatewayAdapters,
-                       $wgDonationInterfaceForbiddenCountries,
-                       $wgDonationInterfacePriceFloor,
-                       $wgDonationInterfacePriceCeiling;
-
-               $wgDonationInterfaceGatewayAdapters['globalcollect'] = 
'TestingGlobalCollectAdapter';
-               $wgDonationInterfaceForbiddenCountries = array();
-               $wgDonationInterfacePriceFloor = 1;
-               $wgDonationInterfacePriceCeiling = 10000;
-
-               $this->subscriptionId = 'SUB-FOO-' . mt_rand();
-               $this->amount = '1.12';
-
-               $this->contributions = array();
-
-               $result = civicrm_api3( 'Contact', 'create', array(
-                       'first_name' => 'Testes',
-                       'contact_type' => 'Individual',
-               ) );
-               $this->contactId = $result['id'];
-
-               $result = civicrm_api3( 'ContributionRecur', 'create', array(
-                       'contact_id' => $this->contactId,
-                       'amount' => $this->amount,
-                       'frequency_interval' => 1,
-                       'frequency_unit' => 'month',
-                       'next_sched_contribution' => 
wmf_common_date_unix_to_civicrm(strtotime('+1 month')),
-                       'installments' => 0,
-                       'processor_id' => 1,
-                       'currency' => 'USD',
-                       'trxn_id' => "RECURRING GLOBALCOLLECT 
{$this->subscriptionId}",
-               ) );
-               $this->contributionRecurId = $result['id'];
-
-               $result = civicrm_api3( 'Contribution', 'create', array(
-                       'contact_id' => $this->contactId,
-                       'contribution_recur_id' => $this->contributionRecurId,
-                       'currency' => 'USD',
-                       'total_amount' => $this->amount,
-                       'contribution_type' => 'Cash',
-                       'payment_instrument' => 'Credit Card',
-                       'trxn_id' => 'RECURRING GLOBALCOLLECT 
STUB_ORIG_CONTRIB-' . mt_rand(),
-               ) );
-               $this->contributions[] = $result['id'];
-               wmf_civicrm_insert_contribution_tracking( '..rcc', 'civicrm', 
null, wmf_common_date_unix_to_sql( strtotime( 'now' ) ), $result['id'] );
-       }
-
-       function testChargeRecorded() {
-
-               // Get some extra access to the testing adapter :(
-               global $wgDonationInterfaceGatewayAdapters;
-               $wgDonationInterfaceGatewayAdapters['globalcollect'] = 
'TestingRecurringStubAdapter';
-
-               // Include using require_once rather than autoload because the 
file
-               // depends on a DonationInterface testing class we loaded above.
-               require_once __DIR__ . '/TestingRecurringStubAdapter.php';
-               TestingRecurringStubAdapter::$singletonDummyGatewayResponseCode 
= 'recurring-OK';
-
-               recurring_globalcollect_charge( $this->contributionRecurId );
-
-               $result = civicrm_api3( 'Contribution', 'get', array(
-                       'contact_id' => $this->contactId,
-               ) );
-               $this->assertEquals( 2, count( $result['values'] ) );
-               foreach ( $result['values'] as $contribution ) {
-                       if ( $contribution['id'] == $this->contributions[0] ) {
-                               // Skip assertions on the synthetic original 
contribution
-                               continue;
-                       }
-
-                       $this->assertEquals( 1,
-                               preg_match( "/^RECURRING GLOBALCOLLECT 
{$this->subscriptionId}-2\$/", $contribution['trxn_id'] ) );
-               }
-       }
-
-       public function testRecurringCharge() {
-               $init = array(
-                       'contribution_tracking_id' => mt_rand(),
-                       'amount' => '2345',
-                       'effort_id' => 2,
-                       'order_id' => '9998890004',
-                       'currency' => 'EUR',
-                       'payment_method' => 'cc',
-               );
-               $gateway = DonationInterfaceFactory::createAdapter( 
'globalcollect', $init );
-
-               $gateway->setDummyGatewayResponseCode( 'recurring-OK' );
-
-               $result = $gateway->do_transaction( 'Recurring_Charge' );
-
-               $this->assertTrue( $result->getCommunicationStatus() );
-               $this->assertRegExp( '/SET_PAYMENT/', $result->getRawResponse() 
);
-       }
-
-       /**
-        * Can make a recurring payment
-        *
-        * @covers GlobalCollectAdapter::transactionRecurring_Charge
-        */
-       public function testDeclinedRecurringCharge() {
-               $init = array(
-                       'contribution_tracking_id' => mt_rand(),
-                       'amount' => '2345',
-                       'effort_id' => 2,
-                       'order_id' => '9998890004',
-                       'currency' => 'EUR',
-                       'payment_method' => 'cc',
-               );
-               $gateway = DonationInterfaceFactory::createAdapter( 
'globalcollect', $init );
-
-               $gateway->setDummyGatewayResponseCode( 'recurring-declined' );
-
-               $result = $gateway->do_transaction( 'Recurring_Charge' );
-
-               $this->assertRegExp( '/GET_ORDERSTATUS/', 
$result->getRawResponse(),
-                       'Stopped after GET_ORDERSTATUS.' );
-               $this->assertEquals( 2, count( $gateway->curled ),
-                       'Expected 2 API calls' );
-               $this->assertEquals( FinalStatus::FAILED, 
$gateway->getFinalStatus() );
-       }
-
-       /**
-        * Throw errors if the payment is incomplete
-        *
-        * @covers GlobalCollectAdapter::transactionRecurring_Charge
-        */
-       public function testRecurringTimeout() {
-               $init = array(
-                       'contribution_tracking_id' => mt_rand(),
-                       'amount' => '2345',
-                       'effort_id' => 2,
-                       'order_id' => '9998890004',
-                       'currency' => 'EUR',
-                       'payment_method' => 'cc',
-               );
-               $gateway = DonationInterfaceFactory::createAdapter( 
'globalcollect', $init );
-
-               $gateway->setDummyGatewayResponseCode( 'recurring-timeout' );
-
-               $result = $gateway->do_transaction( 'Recurring_Charge' );
-
-               $this->assertFalse( $result->getCommunicationStatus() );
-               $this->assertRegExp( '/GET_ORDERSTATUS/', 
$result->getRawResponse() );
-               // FIXME: This is a little funky--the transaction is actually 
pending-poke.
-               $this->assertEquals( FinalStatus::FAILED, 
$gateway->getFinalStatus() );
-       }
-
-       /**
-        * Can resume a recurring payment
-        *
-        * @covers GlobalCollectAdapter::transactionRecurring_Charge
-        */
-       public function testRecurringResume() {
-               $init = array(
-                       'contribution_tracking_id' => mt_rand(),
-                       'amount' => '2345',
-                       'effort_id' => 2,
-                       'order_id' => '9998890004',
-                       'currency' => 'EUR',
-                       'payment_method' => 'cc',
-               );
-               $gateway = DonationInterfaceFactory::createAdapter( 
'globalcollect', $init );
-
-               $gateway->setDummyGatewayResponseCode( 'recurring-resume' );
-
-               $result = $gateway->do_transaction( 'Recurring_Charge' );
-
-               $this->assertTrue( $result->getCommunicationStatus() );
-               $this->assertRegExp( '/SET_PAYMENT/', $result->getRawResponse() 
);
-       }
-
-       /**
-        * Recover from missing ct_ids on all associated contributions
-        */
-       public function testBackfillContributionTracking() {
-               $id_list = implode( ',', $this->contributions );
-
-               $dbs = wmf_civicrm_get_dbs();
-               $dbs->push( 'donations' );
-               $query = "DELETE FROM {contribution_tracking} WHERE 
contribution_id IN( $id_list )";
-               db_query( $query );
-               $contribution_tracking_id = 
recurring_get_contribution_tracking_id( array(
-                       'txn_type' => 'subscr_payment',
-                       'subscr_id' => $this->subscriptionId,
-                       'payment_date' => strtotime( "now" ),
-               ) );
-               $this->assertNotEmpty( $contribution_tracking_id );
-       }
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git a/sites/all/modules/wmf_audit/tests/AmazonAuditTest.php 
b/sites/all/modules/wmf_audit/tests/AmazonAuditTest.php
deleted file mode 100644
index 1a4a21a..0000000
--- a/sites/all/modules/wmf_audit/tests/AmazonAuditTest.php
+++ /dev/null
@@ -1,161 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-
-use SmashPig\Core\Context;
-use SmashPig\PaymentProviders\Amazon\Tests\AmazonTestConfiguration;
-
-/**
- * @group Amazon
- * @group WmfAudit
- */
-class AmazonAuditTest extends BaseWmfDrupalPhpUnitTestCase {
-       static protected $messages;
-
-       protected $contact_id;
-       protected $contribution_id;
-
-       public function setUp() {
-               parent::setUp();
-               self::$messages = array();
-
-               // Use the test configuration for SmashPig
-               $ctx = Context::get();
-               $config = AmazonTestConfiguration::instance( 
$ctx->getGlobalConfiguration() );
-               $ctx->setProviderConfiguration( $config );
-
-               $dirs = array(
-                       'wmf_audit_log_archive_dir' => __DIR__ . '/data/logs/',
-                       'amazon_audit_recon_completed_dir' => 
$this->getTempDir(),
-                       'amazon_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['amazon_audit_working_log_dir'] . 
'*' );
-               foreach ( $old_working as $zap ) {
-                       if ( is_file( $zap ) ) {
-                               unlink( $zap );
-                       }
-               }
-
-               variable_set( 'amazon_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( 
'amazon', 'P01-4968629-7654321-C070794' );
-               if ( $existing ) {
-                       // Previous test run may have crashed before cleaning up
-                       $contribution = $existing[0];
-               } else {
-                       $msg = array(
-                               'contribution_tracking_id' => 2476135333,
-                               'currency' => 'USD',
-                               'date' => 1443724034,
-                               'email' => 'lu...@yahoo.com',
-                               'gateway' => 'amazon',
-                               'gateway_txn_id' => 
'P01-4968629-7654321-C070794',
-                               'gross' => 1.00,
-                               'payment_method' => 'amazon',
-                       );
-                       $contribution = 
wmf_civicrm_contribution_message_import( $msg );
-               }
-               $this->contact_id = $contribution['contact_id'];
-               $this->contribution_id = $contribution['id'];
-       }
-
-       public function tearDown() {
-    $this->callAPISuccess('Contribution', 'delete', array('id' => 
$this->contribution_id));
-    $this->callAPISuccess('Contact', 'delete', array('id' => 
$this->contact_id));
-               parent::tearDown();
-       }
-
-       public function auditTestProvider() {
-               return array(
-                       array( __DIR__ . '/data/Amazon/donation/', array(
-                               'main' => array(
-                                       array(
-                                               'contribution_tracking_id' => 
'87654321',
-                                               'country' => 'US',
-                                               'currency' => 'USD',
-                                               'date' => 1443723034,
-                                               'email' => 
'nonchal...@gmail.com',
-                                               'fee' => '0.59',
-                                               'first_name' => 'Test',
-                                               'gateway' => 'amazon',
-                                               'gateway_account' => 'default',
-                                               'gateway_txn_id' => 
'P01-1488694-1234567-C034811',
-                                               'gross' => '10.00',
-                                               'language' => 'en',
-                                               'last_name' => 'Person',
-                                               'order_id' => '87654321-0',
-                                               'payment_method' => 'amazon',
-                                               'payment_submethod' => '',
-                                               'user_ip' => '1.2.3.4',
-                                               'utm_campaign' => 
'C13_en.wikipedia.org',
-                                               'utm_medium' => 'sidebar',
-                                               'utm_source' => '..amazon',
-                                       ),
-                               ),
-                       ) ),
-                array( __DIR__ . '/data/Amazon/refund/', array(
-                               'negative' => array(
-                                       array(
-                                               'date' => 1444087249,
-                                               'gateway' => 'amazon',
-                                               'gateway_parent_id' => 
'P01-4968629-7654321-C070794',
-                                               'gateway_refund_id' => 
'P01-4968629-7654321-R017571',
-                                               'gross' => '1.00',
-                                               'gross_currency' => 'USD',
-                                               'type' => 'refund',
-                                       ),
-                               ),
-                       ) ),
-                array( __DIR__ . '/data/Amazon/chargeback/', array(
-                               'negative' => array(
-                                       array(
-                                               'date' => 1444087249,
-                                               'gateway' => 'amazon',
-                                               'gateway_parent_id' => 
'P01-4968629-7654321-C070794',
-                                               'gateway_refund_id' => 
'P01-4968629-7654321-R017571',
-                                               'gross' => '1.00',
-                                               'gross_currency' => 'USD',
-                                               'type' => 'chargeback',
-                                       ),
-                               ),
-                       ) ),
-               );
-       }
-
-       /**
-        * @dataProvider auditTestProvider
-        */
-       public function testParseFiles( $path, $expectedMessages ) {
-               variable_set( 'amazon_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( 'AmazonAuditTest', 
'receiveMessages' ),
-                       #'verbose' => 'true', # Uncomment to debug.
-               );
-               $audit = new AmazonAuditProcessor( $options );
-               $audit->run();
-       }
-
-       static public function receiveMessages( $msg, $type ) {
-               self::$messages[$type][] = $msg;
-       }
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git 
a/sites/all/modules/wmf_civicrm/tests/phpunit/DonationInterfaceFactoryTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/DonationInterfaceFactoryTest.php
deleted file mode 100644
index 04125de..0000000
--- 
a/sites/all/modules/wmf_civicrm/tests/phpunit/DonationInterfaceFactoryTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-
-/**
- * Helps us not break the DonationInterfaceFactory gateway adapter wrapper
- *
- * @group WmfCivicrm
- */
-class DonationInterfaceFactoryTest extends BaseWmfDrupalPhpUnitTestCase {
-
-       /**
-        * Do we blow up on the launch pad?
-        */
-       public function testCreateAdapter() {
-               $values = array(
-                       'amount' => 9.99,
-                       'effort_id' => 1,
-                       'order_id' => mt_rand(),
-                       'currency' => 'USD',
-                       'payment_method' => 'cc',
-                       'language' => 'en',
-                       'contribution_tracking_id' => mt_rand(),
-                       'referrer' => 'dummy',
-               );
-               $adapter = DonationInterfaceFactory::createAdapter( 
'globalcollect', $values );
-               // see FIXME in recurring globalcollect
-               $adapter->addRequestData( array(
-                       'effort_id' => 1,
-               ) );
-               $data = $adapter->getData_Unstaged_Escaped();
-               foreach ( $values as $key => $value ) {
-                       $this->assertEquals( $value, $data[$key], "$key is 
being mangled in adapter construction" );
-               }
-       }
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git 
a/sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php 
b/sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
deleted file mode 100644
index 377595b..0000000
--- 
a/sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
+++ /dev/null
@@ -1,180 +0,0 @@
-<<<<<<< HEAD   (461900 Merge "Merge branch 'master' of 
https://gerrit.wikimedia.org)
-=======
-<?php
-
-use SmashPig\Core\Context;
-use SmashPig\Tests\TestingContext;
-use SmashPig\Tests\TestingGlobalConfiguration;
-
-class BaseWmfDrupalPhpUnitTestCase extends PHPUnit_Framework_TestCase {
-    public function setUp() {
-        parent::setUp();
-
-        // Initialize SmashPig with a fake context object
-        $config = TestingGlobalConfiguration::create();
-        TestingContext::init( $config );
-
-        if ( !defined( 'DRUPAL_ROOT' ) ) {
-            throw new Exception( "Define DRUPAL_ROOT somewhere before running 
unit tests." );
-        }
-
-        global $user, $_exchange_rate_cache;
-        $GLOBALS['_PEAR_default_error_mode'] = NULL;
-        $GLOBALS['_PEAR_default_error_options'] = NULL;
-        $_exchange_rate_cache = array();
-
-        $user = new stdClass();
-        $user->name = "foo_who";
-        $user->uid = "321";
-        $user->roles = array( DRUPAL_AUTHENTICATED_RID => 'authenticated user' 
);
-    }
-
-    public function tearDown() {
-               Context::set( null ); // Nullify any SmashPig context for the 
next run
-               parent::tearDown();
-       }
-
-       /**
-        * Temporarily set foreign exchange rates to known values
-        *
-        * TODO: Should reset after each test.
-        */
-       protected function setExchangeRates( $timestamp, $rates ) {
-               foreach ( $rates as $currency => $rate ) {
-                       exchange_rate_cache_set( $currency, $timestamp, $rate );
-               }
-       }
-
-       /**
-        * Create a temporary directory and return the name
-        * @return string|boolean directory path if creation was successful, or 
false
-        */
-       protected function getTempDir() {
-               $tempFile = tempnam( sys_get_temp_dir(), 'wmfDrupalTest_' );
-               if ( file_exists( $tempFile ) ) {
-                       unlink( $tempFile );
-               }
-               mkdir( $tempFile );
-               if ( is_dir( $tempFile ) ) {
-                       return $tempFile . '/';
-               }
-               return false;
-       }
-
-    /**
-     * API wrapper function from core (more or less).
-     *
-     * so we can ensure they succeed & throw exceptions without littering the 
test with checks.
-     *
-     * This is not the full function but it we think it'w worth keeping a copy 
it should maybe
-     * go in the parent.
-     *
-     * @param string $entity
-     * @param string $action
-     * @param array $params
-     * @param mixed $checkAgainst
-     *   Optional value to check result against, implemented for getvalue,.
-     *   getcount, getsingle. Note that for getvalue the type is checked 
rather than the value
-     *   for getsingle the array is compared against an array passed in - the 
id is not compared (for
-     *   better or worse )
-     *
-     * @return array|int
-     */
-    public function callAPISuccess($entity, $action, $params, $checkAgainst = 
NULL) {
-        $params = array_merge(array(
-            'version' => 3,
-            'debug' => 1,
-        ),
-            $params
-        );
-        try {
-            $result = civicrm_api3($entity, $action, $params);
-        }
-        catch (CiviCRM_API3_Exception $e) {
-            $this->assertEquals(0, $e->getMessage() . 
print_r($e->getExtraParams(), TRUE));
-        }
-        $this->assertAPISuccess($result, "Failure in api call for $entity 
$action");
-        return $result;
-    }
-
-    /**
-     * Check that api returned 'is_error' => 0.
-     *
-     * @param array $apiResult
-     *   Api result.
-     * @param string $prefix
-     *   Extra test to add to message.
-     */
-    public function assertAPISuccess($apiResult, $prefix = '') {
-        if (!empty($prefix)) {
-            $prefix .= ': ';
-        }
-        $errorMessage = empty($apiResult['error_message']) ? '' : " " . 
$apiResult['error_message'];
-
-        if (!empty($apiResult['debug_information'])) {
-            $errorMessage .= "\n " . print_r($apiResult['debug_information'], 
TRUE);
-        }
-        if (!empty($apiResult['trace'])) {
-            $errorMessage .= "\n" . print_r($apiResult['trace'], TRUE);
-        }
-        $this->assertEquals(0, $apiResult['is_error'], $prefix . 
$errorMessage);
-    }
-
-  /**
-   * Getsingle test function from civicrm core codebase test suite.
-   *
-   * This function exists to wrap api getsingle function & check the result
-   * so we can ensure they succeed & throw exceptions without litterering the 
test with checks
-   *
-   * @param string $entity
-   * @param array $params
-   *
-   * @throws Exception
-   * @return array|int
-   */
-  public function callAPISuccessGetSingle($entity, $params) {
-    $params += array(
-      'version' => 3,
-      'debug' => 1,
-    );
-    $result = civicrm_api($entity, 'getsingle', $params);
-    if (!is_array($result) || !empty($result['is_error']) || 
isset($result['values'])) {
-      throw new Exception('Invalid getsingle result' . print_r($result, TRUE));
-    }
-    return $result;
-  }
-
-  /**
-   * Emulate a logged in user since certain functions use that.
-   * value to store a record in the DB (like activity)
-   * CRM-8180
-   *
-   * @return int
-   *   Contact ID of the created user.
-   */
-  public function imitateAdminUser() {
-    $result = $this->callAPISuccess('UFMatch', 'get', array(
-      'uf_id' => 1,
-      'sequential' => 1,
-    ));
-    if (empty($result['id'])) {
-      $contact = $this->callAPISuccess('Contact', 'create', array(
-        'first_name' => 'Super',
-        'last_name' => 'Duper',
-        'contact_type' => 'Individual',
-        'api.UFMatch.create' => array('uf_id' => 1, 'uf_name' => 'Wizard'),
-      ));
-      $contactID = $contact['id'];
-    }
-    else {
-      $contactID = $result['values'][0]['contact_id'];
-    }
-    $session = CRM_Core_Session::singleton();
-    $session->set('userID', $contactID);
-    CRM_Core_Config::singleton()->userPermissionClass = new 
CRM_Core_Permission_UnitTests();
-    CRM_Core_Config::singleton()->userPermissionClass->permissions = 
array('Edit All Contacts', 'Access CiviCRM', 'Administer CiviCRM');
-    return $contactID;
-  }
-
-}
->>>>>>> BRANCH (84cb2f Merge "Update SmashPig and DonationInterface")
diff --git a/vendor b/vendor
index 9673cc8..5449ec1 160000
--- a/vendor
+++ b/vendor
@@ -1 +1 @@
-Subproject commit 9673cc835b4410331258f291ecb37db0c6264d29
+Subproject commit 5449ec1076ea3a6fd42e376fe7bc8b13b885ad2b

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3190ba4a900e178865a2c443a6f64a7ef2c852ec
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: deployment
Gerrit-Owner: Ejegg <ej...@ejegg.com>

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

Reply via email to