Ejegg has uploaded a new change for review.

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

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

Merge branch 'master' into deployment

and delete tests

877bc6c Backfill wmf_contribution_extra
2cf9d34 Add hook & tests for address handling.
ca2b00a Add test/ handling to treat conflicts on email=on_hold as conflicts.
9bccac7 Send failmail instead of throwing exception on mismatched refund.
6ba7ae0 Fix incorrect contribution_recur rows
8b594b3 Update CiviCRM submodule
38cfe17 WmfQueueConsumer to replace dequeue_loop
8730ca7 Drush merge command
9fab588 Fix ProcessMessageTest to not fail on exchange rates.
d980aa1 Failmail can unpack multiple "to" addresses

Change-Id: I085e0d7afb98fa126c4003d3bebe33971740a763
---
D sites/all/modules/queue2civicrm/tests/phpunit/ProcessMessageTest.php
D sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
D sites/all/modules/wmf_civicrm/tests/phpunit/RefundTest.php
D sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
M sites/all/modules/wmf_common/wmf_common.info
5 files changed, 0 insertions(+), 1,500 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/95/303695/1

diff --git 
a/sites/all/modules/queue2civicrm/tests/phpunit/ProcessMessageTest.php 
b/sites/all/modules/queue2civicrm/tests/phpunit/ProcessMessageTest.php
deleted file mode 100644
index 1fbc44a..0000000
--- a/sites/all/modules/queue2civicrm/tests/phpunit/ProcessMessageTest.php
+++ /dev/null
@@ -1,274 +0,0 @@
-<<<<<<< HEAD   (f138a2 Remove some tests from the deployment branch)
-=======
-<?php
-
-/**
- * @group Pipeline
- * @group Queue2Civicrm
- */
-class ProcessMessageTest extends BaseWmfDrupalPhpUnitTestCase {
-    public static function getInfo() {
-        return array(
-            'name' => 'Process Message',
-            'group' => 'Pipeline',
-            'description' => 'Push messages through the queue intake 
functions.',
-        );
-    }
-
-    /**
-     * Process an ordinary (one-time) donation message
-     */
-    public function testDonation() {
-        $message = new TransactionMessage();
-        $message2 = new TransactionMessage();
-
-        exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
-        exchange_rate_cache_set( $message->get( 'currency' ), $message->get( 
'date' ), 3 );
-
-        queue2civicrm_import( $message );
-        queue2civicrm_import( $message2 );
-
-        $contributions = wmf_civicrm_get_contributions_from_gateway_id( 
$message->getGateway(), $message->getGatewayTxnId() );
-        $this->assertEquals( 1, count( $contributions ) );
-
-        $contributions2 = wmf_civicrm_get_contributions_from_gateway_id( 
$message2->getGateway(), $message2->getGatewayTxnId() );
-        $this->assertEquals( 1, count( $contributions2 ) );
-
-        $this->assertNotEquals( $contributions[0]['contact_id'], 
$contributions2[0]['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 );
-
-        queue2civicrm_import( $message );
-
-        $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);
-
-      queue2civicrm_import($message);
-
-      $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);
-
-    queue2civicrm_import($message);
-
-    $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);
-  }
-
-  /**
-   * 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) {
-        $appealField = civicrm_api3('custom_field', 'getsingle', array('name' 
=> $fieldName));
-        civicrm_api3('OptionValue', 'create', array(
-          'name' => $optionValue,
-          'value' => $optionValue,
-          'option_group_id' => $appealField['option_group_id'],
-          'is_active' => $is_active,
-        ));
-        
civicrm_api_option_group(wmf_civicrm_get_direct_mail_field_option_name(), null, 
TRUE);
-        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'];
-    }
-
-    public function testRecurring() {
-        $subscr_id = mt_rand();
-        $values = array( 'subscr_id' => $subscr_id );
-        $signup_message = new RecurringSignupMessage( $values );
-        $message = new RecurringPaymentMessage( $values );
-        $message2 = new RecurringPaymentMessage( $values );
-
-        $subscr_time = strtotime( $signup_message->get( 'subscr_date' ) );
-        exchange_rate_cache_set( 'USD', $subscr_time, 1 );
-        exchange_rate_cache_set( $signup_message->get('mc_currency'), 
$subscr_time, 3 );
-        $payment_time = strtotime( $message->get( 'payment_date' ) );
-        exchange_rate_cache_set( 'USD', $payment_time, 1 );
-        exchange_rate_cache_set( $message->get('mc_currency'), $payment_time, 
3 );
-
-        recurring_import( $signup_message );
-        recurring_import( $message );
-        recurring_import( $message2 );
-
-        $recur_record = wmf_civicrm_get_recur_record( $subscr_id );
-        $this->assertNotEquals( false, $recur_record );
-
-        $contributions = wmf_civicrm_get_contributions_from_gateway_id( 
$message->getGateway(), $message->getGatewayTxnId() );
-        $this->assertEquals( 1, count( $contributions ) );
-        $this->assertEquals( $recur_record->id, 
$contributions[0]['contribution_recur_id']);
-
-        $contributions2 = wmf_civicrm_get_contributions_from_gateway_id( 
$message2->getGateway(), $message2->getGatewayTxnId() );
-        $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'] );
-    }
-
-    /**
-     * @expectedException WmfException
-     * @expectedExceptionCode WmfException::MISSING_PREDECESSOR
-     */
-    public function testRecurringNoPredecessor() {
-        $message = new RecurringPaymentMessage( array(
-            'subscr_id' => mt_rand(),
-        ) );
-
-        $payment_time = strtotime( $message->get( 'payment_date' ) );
-        exchange_rate_cache_set( 'USD', $payment_time, 1 );
-        exchange_rate_cache_set( $message->get('mc_currency'), $payment_time, 
3 );
-
-        recurring_import( $message );
-    }
-
-    /**
-     * @expectedException WmfException
-     * @expectedExceptionCode WmfException::INVALID_RECURRING
-     */
-    public function testRecurringNoSubscrId() {
-        $message = new RecurringPaymentMessage( array(
-            'subscr_id' => null,
-        ) );
-
-        $payment_time = strtotime( $message->get( 'payment_date' ) );
-        exchange_rate_cache_set( 'USD', $payment_time, 1 );
-        exchange_rate_cache_set( $message->get('mc_currency'), $payment_time, 
3 );
-
-        recurring_import( $message );
-    }
-
-    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 );
-
-        queue2civicrm_import( $donation_message );
-        $contributions = wmf_civicrm_get_contributions_from_gateway_id( 
$donation_message->getGateway(), $donation_message->getGatewayTxnId() );
-        $this->assertEquals( 1, count( $contributions ) );
-
-        refund_import( $refund_message );
-        $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();
-
-        refund_import( $refund_message );
-    }
-
-    /**
-     * 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 queue2civicrm_import 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' ),
-        ) );
-
-        queue2civicrm_import( $donation_message );
-        $contributions = wmf_civicrm_get_contributions_from_gateway_id( 
$donation_message->getGateway(), $donation_message->getGatewayTxnId() );
-        $this->assertEquals( 1, count( $contributions ) );
-
-        refund_import( $refund_message );
-        $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 (d980aa Failmail can unpack multiple "to" addresses)
diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
deleted file mode 100644
index fb6174b..0000000
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
+++ /dev/null
@@ -1,816 +0,0 @@
-<<<<<<< HEAD   (f138a2 Remove some tests from the deployment branch)
-=======
-<?php
-
-/**
- * @group Pipeline
- * @group WmfCivicrm
- */
-class MergeTest extends BaseWmfDrupalPhpUnitTestCase {
-
-  /**
-   * Id of the contact created in the setup function.
-   *
-   * @var int
-   */
-  protected $contactID;
-
-  /**
-   * Id of the contact created in the setup function.
-   *
-   * @var int
-   */
-  protected $contactID2;
-
-  public function setUp() {
-    parent::setUp();
-    civicrm_initialize();
-    $this->imitateAdminUser();
-    $this->doDuckHunt();
-    // Run through the merge first to make sure there aren't pre-existing 
contacts in the DB
-    // that will ruin the tests.
-    $this->callAPISuccess('Job', 'process_batch_merge', array('mode' => 
'safe'));
-    $contact = $this->callAPISuccess('Contact', 'create', array(
-      'contact_type' => 'Individual',
-      'first_name' => 'Donald',
-      'last_name' => 'Duck',
-      'api.email.create' => array('email' => 'the_...@duckland.com', 
'location_type_id' => 'Work'),
-      wmf_civicrm_get_custom_field_name('do_not_solicit') => 0,
-    ));
-    $this->contactID = $contact['id'];
-
-    $contact = $this->callAPISuccess('Contact', 'create', array(
-      'contact_type' => 'Individual',
-      'first_name' => 'Donald',
-      'last_name' => 'Duck',
-      'api.email.create' => array('email' => 'the_...@duckland.com', 
'location_type_id' => 'Work'),
-      wmf_civicrm_get_custom_field_name('do_not_solicit') => 1,
-    ));
-    $this->contactID2 = $contact['id'];
-  }
-
-  public function tearDown() {
-    $this->callAPISuccess('Contribution', 'get', array(
-      'contact_id' => array('IN' => array($this->contactID, 
$this->contactID2)),
-      'api.Contribution.delete' => 1,
-    ));
-    $this->callAPISuccess('Contact', 'delete', array('id' => 
$this->contactID));
-    $this->callAPISuccess('Contact', 'delete', array('id' => 
$this->contactID2));
-    parent::tearDown();
-  }
-
-  /**
-   * Test that the merge hook causes our custom fields to not be treated as 
conflicts.
-   *
-   * We also need to check the custom data fields afterwards.
-   */
-  public function testMergeHook() {
-    $this->callAPISuccess('Contribution', 'create', array(
-      'contact_id' => $this->contactID,
-      'financial_type_id' => 'Cash',
-      'total_amount' => 10,
-      'currency' => 'USD',
-      // Should cause 'is_2014 to be true.
-      'receive_date' => '2014-08-04',
-      wmf_civicrm_get_custom_field_name('original_currency') => 'NZD',
-      wmf_civicrm_get_custom_field_name('original_amount') => 8,
-    ));
-    $this->callAPISuccess('Contribution', 'create', array(
-      'contact_id' => $this->contactID2,
-      'financial_type_id' => 'Cash',
-      'total_amount' => 5,
-      'currency' => 'USD',
-      // Should cause 'is_2012_donor to be true.
-      'receive_date' => '2013-01-04',
-    ));
-    $this->callAPISuccess('Contribution', 'create', array(
-      'contact_id' => $this->contactID2,
-      'financial_type_id' => 'Cash',
-      'total_amount' => 9,
-      'currency' => 'NZD',
-      // Should cause 'is_2015_donor to be true.
-      'receive_date' => '2016-04-04',
-    ));
-    $contact = $this->callAPISuccess('Contact', 'get', array(
-      'id' => $this->contactID,
-      'sequential' => 1,
-      'return' => 
array(wmf_civicrm_get_custom_field_name('lifetime_usd_total'), 
wmf_civicrm_get_custom_field_name('do_not_solicit')),
-    ));
-    $this->assertEquals(10, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('lifetime_usd_total')]);
-    $result = $this->callAPISuccess('Job', 'process_batch_merge', array(
-      'criteria' => array('contact' => array('id' => array('IN' => 
array($this->contactID, $this->contactID2)))),
-    ));
-    $this->assertEquals(1, count($result['values']['merged']));
-    $contact = $this->callAPISuccess('Contact', 'get', array(
-      'id' => $this->contactID,
-      'sequential' => 1,
-      'return' => array(
-        wmf_civicrm_get_custom_field_name('lifetime_usd_total'),
-        wmf_civicrm_get_custom_field_name('do_not_solicit'),
-        wmf_civicrm_get_custom_field_name('last_donation_amount'),
-        wmf_civicrm_get_custom_field_name('last_donation_currency'),
-        wmf_civicrm_get_custom_field_name('last_donation_usd'),
-        wmf_civicrm_get_custom_field_name('last_donation_date'),
-        wmf_civicrm_get_custom_field_name('is_2011_donor'),
-        wmf_civicrm_get_custom_field_name('is_2012_donor'),
-        wmf_civicrm_get_custom_field_name('is_2013_donor'),
-        wmf_civicrm_get_custom_field_name('is_2014_donor'),
-        wmf_civicrm_get_custom_field_name('is_2015_donor'),
-        wmf_civicrm_get_custom_field_name('is_2016_donor'),
-      ),
-    ));
-    $this->assertEquals(24, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('lifetime_usd_total')]);
-    $this->assertEquals(1, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('do_not_solicit')]);
-    $this->assertEquals(0, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('is_2011_donor')]);
-    $this->assertEquals(1, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('is_2012_donor')]);
-    $this->assertEquals(0, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('is_2013_donor')]);
-    $this->assertEquals(1, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('is_2014_donor')]);
-    $this->assertEquals(1, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('is_2015_donor')]);
-    $this->assertEquals(0, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('is_2016_donor')]);
-    $this->assertEquals(9, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('last_donation_amount')]);
-    $this->assertEquals(9, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('last_donation_usd')]);
-    $this->assertEquals('2016-04-04 00:00:00', 
$contact['values'][0][wmf_civicrm_get_custom_field_name('last_donation_date')]);
-    $this->assertEquals('NZD', 
$contact['values'][0][wmf_civicrm_get_custom_field_name('last_donation_currency')]);
-
-    // Now lets check the one to be deleted has a do_not_solicit = 0.
-    $this->callAPISuccess('Contact', 'create', array(
-      'contact_type' => 'Individual',
-      'first_name' => 'Donald',
-      'last_name' => 'Duck',
-      'email' => 'the_...@duckland.com',
-      wmf_civicrm_get_custom_field_name('do_not_solicit') => 0,
-    ));
-    $result = $this->callAPISuccess('Job', 'process_batch_merge', array(
-      'criteria' => array('contact' => array('id' => $this->contactID)),
-    ));
-    $this->assertEquals(1, count($result['values']['merged']));
-    $contact = $this->callAPISuccess('Contact', 'get', array(
-      'id' => $this->contactID,
-      'sequential' => 1,
-      'return' => 
array(wmf_civicrm_get_custom_field_name('lifetime_usd_total'), 
wmf_civicrm_get_custom_field_name('do_not_solicit')),
-    ));
-    $this->assertEquals(1, 
$contact['values'][0][wmf_civicrm_get_custom_field_name('do_not_solicit')]);
-  }
-
-  /**
-   * Test altering the address decision by hook.
-   *
-   * I feel I did something a bit sneaky here. I actually wrote both the test 
and
-   * the hook against the core repo and committed in in this test.
-   *
-   * I figured that made core more robust & helped future proof us.
-   *
-   * 
https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/JobTest.php#L584
-   * 
https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/JobTest.php#L643
-   *
-   * However, I'm replicating the test into our repo to test it still works 
distilled
-   * into our hook.
-   *
-   * Tested scenarios: Note these apply to addresses, phones & emails.
-   *
-   *  1) (Fill data) both contacts have the same primary with the same 
location (Home). The first has an additional address (Mailing).
-   *      Outcome: common primary is retained as the Home address & additional 
Mailing address is retained on the merged contact.
-   *      Notes: our behaviour is the same as core.
-   *  2) (Fill data) (reverse of 1) both contacts have the same primary with 
the same location (Home).
-   *      The second has an additional  address (Mailing).
-   *      Outcome: common primary is retained & additional Mailing address is 
retained on the merged contact.
-   *      Notes: our behaviour is the same as core.
-   *  3) (Fill data)  only one contact has an address (Home) - first contact.
-   *     Outcome: address retained
-   *     Notes: our behaviour is the same as core.
-   *  4) (Fill data) (reverse of 3) only one contact has an address (Home) - 
second contact.
-   *     Outcome: address retained
-   *     Notes: our behaviour is the same as core.
-   *  5) (Resolve Data) Contacts have different primary addresses with 
different
-   *     location types. ie. first has a primary Home address. Second has a 
primary
-   *     Mailing address. Addresses Differ.
-   *     Outcome: keep both addresses. Use the address of the later donor as 
the primary.
-   *     Notes: differs from core behaviour which would keep the address of 
the contact
-   *     with the lower contact_id as the primary
-   *  6) (Resolve Data) (reverse of 5) Contacts have different primary 
addresses with different
-   *     location types. ie. first has a primary Mailing address.  Second has 
a primary
-   *     Home address. Addresses Differ.
-   *     Outcome: keep both addresses. Use the address of the later donor as 
the primary.
-   *     Notes: differs from core behaviour which would keep the address of 
the contact
-   *     with the lower contact_id as the primary
-   *  7) (Resolve Data) Contacts have the same Home address. For the first the 
Home
-   *     address is primary. For the second a (different) mailing address is.
-   *     Outcome: both addresses kept. The one that is primary for the later 
donor is primary.
-   *     Notes: same as 5 & 6 but with an additional address. Differs from 
core which
-   *     would set primary to match to lower contact_id.
-   *  8) (Resolve Data) (reverse of 7) Contacts have the same Mailing address. 
For the first
-   *     the Mailing address is primary. For the second a (different) home 
address is.
-   *     Outcome: both addresses kept. The one that is primary for the later 
donor is primary.
-   *     Notes: same as 5 & 6 but with an additional address. Differs from 
core which
-   *     would set primary to match to lower contact_id.
-   *  9) (Resolve Data) Contacts have the same primary address but for the 
first
-   *     contact is is Home whereas for the second is is Mailing.
-   *     Outcome: keep the address. Use the Mailing location of the later 
donor (the second).
-   *     Notes: differs from core behaviour which would keep 2 copies of the 
address with
-   *     2 locations.
-   * 10) (Resolve Data) (reverse of 9) Contacts have the same primary address 
but for the first
-   *     contact is is Mailing whereas for the second is is Home.
-   *     Outcome: keep the address. Use the Home location of the later donor 
(the second).
-   *     Notes: differs from core behaviour which would keep 2 copies of the 
address with
-   *     2 locations.
-   * 11) (Throw conflict) Contacts have conflicting home address. Total giving 
= $500.
-   *     Outcome: conflict - do not merge.
-   *     Notes: This is like core, but for us less than 500 will merge.
-   * 12) (Resolve Data)  Contacts have conflicting home address. Total giving 
< $500.
-   *     Outcome: merge - only keep home address of latest donor.
-   *     Notes: differs from core.
-   * 13) (Throw conflict) Contacts have conflicting home address and matching 
primary (Mailing). Total giving = $500.
-   *     Outcome: conflict - do not merge.
-   *     Notes: This is like core, but for us less than 500 will merge.
-   * 14) (Resolve Data)  Contacts have conflicting home address. Total giving 
< $500.
-   *     Outcome: merge - only keep home address of latest donor. Keep Mailing.
-   *     Notes: differs from core.
-   *
-   * @dataProvider getMergeLocationData
-   *
-   * @param array $dataSet
-   */
-  public function testBatchMergesAddressesHook($dataSet) {
-    $this->contributionCreate(array('contact_id' => $this->contactID, 
'receive_date' => '2010-01-01', 'invoice_id' => 1, 'trxn_id' => 1));
-    $this->contributionCreate(array('contact_id' => $this->contactID2, 
'receive_date' => '2012-01-01', 'invoice_id' => 2, 'trxn_id' => 2));
-    if ($dataSet['is_major_gifts']) {
-      $this->contributionCreate(array('contact_id' => $this->contactID2, 
'receive_date' => '2012-01-01', 'total_amount' => 300));
-    }
-    foreach ($dataSet['contact_1'] as $address) {
-      $this->callAPISuccess($dataSet['entity'], 'create', 
array_merge(array('contact_id' => $this->contactID), $address));
-    }
-    foreach ($dataSet['contact_2'] as $address) {
-      $this->callAPISuccess($dataSet['entity'], 'create', 
array_merge(array('contact_id' => $this->contactID2), $address));
-    }
-
-    $result = $this->callAPISuccess('Job', 'process_batch_merge', array('mode' 
=> 'safe'));
-
-    $this->assertEquals($dataSet['skipped'], 
count($result['values']['skipped']));
-    $this->assertEquals($dataSet['merged'], 
count($result['values']['merged']));
-    $addresses = $this->callAPISuccess($dataSet['entity'], 'get', 
array('contact_id' => $this->contactID, 'sequential' => 1));
-    $this->assertEquals(count($dataSet['expected_hook']), $addresses['count']);
-    $locationTypes = $this->callAPISuccess($dataSet['entity'], 'getoptions', 
array('field' => 'location_type_id'));
-    foreach ($dataSet['expected_hook'] as $index => $expectedAddress) {
-      foreach ($expectedAddress as $key => $value) {
-        if ($key == 'location_type_id') {
-          
$this->assertEquals($locationTypes['values'][$addresses['values'][$index][$key]],
 $value);
-        }
-        else {
-          $this->assertEquals($value, $addresses['values'][$index][$key], 
$dataSet['entity'] . ': Unexpected value for ' . $key . 
(!empty($dataSet['description']) ? " on dataset {$dataSet['description']}" : 
''));
-        }
-      }
-    }
-  }
-
-  /**
-   * Test that a conflict on 'on_hold' is handled.
-   */
-  public function testBatchMergeConflictOnHold() {
-    $emailDuck1 = $this->callAPISuccess('Email', 'get', array('contact_id' => 
$this->contactID, 'return' => 'id'));
-    $emailDuck2 = $this->callAPISuccess('Email', 'get', array('contact_id' => 
$this->contactID2, 'return' => 'id'));
-
-    $this->callAPISuccess('Email', 'create', array('id' => $emailDuck1['id'], 
'on_hold' => 1));
-    $result = $this->callAPISuccess('Job', 'process_batch_merge', array('mode' 
=> 'safe'));
-    $this->assertEquals(1, count($result['values']['skipped']));
-    $this->assertEquals(0, count($result['values']['merged']));
-
-    $this->callAPISuccess('Email', 'create', array('id' => $emailDuck1['id'], 
'on_hold' => 0));
-    $this->callAPISuccess('Email', 'create', array('id' => $emailDuck2['id'], 
'on_hold' => 1));
-    $result = $this->callAPISuccess('Job', 'process_batch_merge', array('mode' 
=> 'safe'));
-    $this->assertEquals(1, count($result['values']['skipped']));
-    $this->assertEquals(0, count($result['values']['merged']));
-
-    $this->callAPISuccess('Email', 'create', array('id' => $emailDuck1['id'], 
'on_hold' => 1));
-    $result = $this->callAPISuccess('Job', 'process_batch_merge', array('mode' 
=> 'safe'));
-    $this->assertEquals(0, count($result['values']['skipped']));
-    $this->assertEquals(1, count($result['values']['merged']));
-  }
-
-  /**
-   * Get address combinations for the merge test.
-   *
-   * @return array
-   */
-  public function getMergeLocationData() {
-    $address1 = array('street_address' => 'Buckingham Palace', 'city' => 
'London');
-    $address2 = array('street_address' => 'The Doghouse', 
'supplemental_address_1' => 'under the blanket');
-    $address3 = array('street_address' => 'Downton Abbey');
-    $data = $this->getMergeLocations($address1, $address2, $address3, 
'Address');
-    $data = array_merge($data, $this->getMergeLocations(
-      array('phone' => '12345', 'phone_type_id' => 1),
-      array('phone' => '678910', 'phone_type_id' => 1),
-      array('phone' => '999888', 'phone_type_id' => 1),
-      'Phone')
-    );
-    $data = array_merge($data, $this->getMergeLocations(array('phone' => 
'12345'), array('phone' => '678910'), array('phone' => '678999'), 'Phone'));
-    $data = array_merge($data, $this->getMergeLocations(
-      array('email' => 'm...@me.com'),
-      array('email' => 'm...@me.org'),
-      array('email' => 'm...@me.co.nz'),
-      'Email',
-      array(array(
-        'email' => 'the_...@duckland.com',
-        'location_type_id' => 'Work',
-    ))));
-    return $data;
-
-  }
-
-  /**
-   * Get the location data set.
-   *
-   * @param array $locationParams1
-   * @param array $locationParams2
-   * @param string $entity
-   * @param array $additionalExpected
-   *
-   * @return array
-   */
-  public function getMergeLocations($locationParams1, $locationParams2, 
$locationParams3, $entity, $additionalExpected = array()) {
-    $data = array(
-      1 => array(
-        'matching_primary' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'description' => 'Same behaviour with & without the hook, matching 
primary AND other address maintained',
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          )),
-        ),
-      ),
-      2 => array(
-        'matching_primary_reverse' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'description' => 'Same behaviour with & without the hook, matching 
primary AND other address maintained',
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      3 => array(
-        'only_one_has_address' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'description' => 'Same behaviour with & without the hook, address is 
maintained',
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          ),
-          'contact_2' => array(),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              // When dealing with email we don't have a clean slate - the 
existing
-              // primary will be primary.
-              'is_primary' => ($entity == 'Email' ? 0 : 1),
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      4 => array(
-        'only_one_has_address_reverse' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'description' => 'Same behaviour with & without the hook, address is 
maintained',
-          'entity' => $entity,
-          'contact_1' => array(),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      5 => array(
-        'different_primaries_with_different_location_type' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'description' => 'Primaries are different with different location. 
Keep both addresses. Set primary to be that of more recent donor',
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      6 => array(
-        'different_primaries_with_different_location_type_reverse' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          )),
-        ),
-      ),
-      7 => array(
-        'different_primaries_location_match_only_one_address' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      8 => array(
-        'different_primaries_location_match_only_one_address_reverse' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 0,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      9 => array(
-        'same_primaries_different_location' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams1),
-
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams1),
-          )),
-        ),
-      ),
-      10 => array(
-        'same_primaries_different_location_reverse' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 1,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          )),
-        ),
-      ),
-      11 => array(
-        'conflicting_home_address_major_gifts' => array(
-          'merged' => 0,
-          'skipped' => 1,
-          'is_major_gifts' => 1,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          )),
-        ),
-      ),
-      12 => array(
-        'conflicting_home_address_not_major_gifts' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 0,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams1),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 1,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      13 => array(
-        'conflicting_home_address_one_more_major_gifts' => array(
-          'merged' => 0,
-          'skipped' => 1,
-          'is_major_gifts' => 1,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams3),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-      14 => array(
-        'conflicting_home_address__one_more_not_major_gifts' => array(
-          'merged' => 1,
-          'skipped' => 0,
-          'is_major_gifts' => 0,
-          'entity' => $entity,
-          'contact_1' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams1),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'contact_2' => array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams3),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          ),
-          'expected_hook' => array_merge($additionalExpected, array(
-            array_merge(array(
-              'location_type_id' => 'Home',
-              'is_primary' => 0,
-            ), $locationParams3),
-            array_merge(array(
-              'location_type_id' => 'Mailing',
-              'is_primary' => 1,
-            ), $locationParams2),
-          )),
-        ),
-      ),
-    );
-    return $data;
-  }
-
-
-  /**
-   * Clean up previous runs.
-   *
-   * Also get rid of the nest.
-   */
-  protected function doDuckHunt() {
-    CRM_Core_DAO::executeQuery('DELETE FROM civicrm_contact WHERE display_name 
= "Donald Duck"');
-    CRM_Core_DAO::executeQuery('DELETE FROM civicrm_prevnext_cache');
-  }
-
-  /**
-   * Create contribution.
-   *
-   * @param array $params
-   *   Array of parameters.
-   *
-   * @return int
-   *   id of created contribution
-   */
-  public function contributionCreate($params) {
-
-    $params = array_merge(array(
-      'receive_date' => date('Ymd'),
-      'total_amount' => 100.00,
-      'fee_amount' => 5.00,
-      'net_ammount' => 95.00,
-      'financial_type_id' => 1,
-      'payment_instrument_id' => 1,
-      'non_deductible_amount' => 10.00,
-      'contribution_status_id' => 1,
-    ), $params);
-
-    $result = $this->callAPISuccess('contribution', 'create', $params);
-    return $result['id'];
-  }
-
-}
->>>>>>> BRANCH (d980aa Failmail can unpack multiple "to" addresses)
diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/RefundTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/RefundTest.php
deleted file mode 100644
index 2355c3b..0000000
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/RefundTest.php
+++ /dev/null
@@ -1,264 +0,0 @@
-<<<<<<< HEAD   (f138a2 Remove some tests from the deployment branch)
-=======
-<?php
-
-use wmf_communication\TestMailer;
-
-/**
- * @group Pipeline
- * @group WmfCivicrm
- */
-class RefundTest extends BaseWmfDrupalPhpUnitTestCase {
-
-    /**
-     * Id of the contribution created in the setup function.
-     *
-     * @var int
-     */
-    protected $original_contribution_id;
-
-    public function setUp() {
-        parent::setUp();
-        civicrm_initialize();
-        TestMailer::setup();
-
-        $results = $this->callAPISuccess( 'contact', 'create', array(
-            'contact_type' => 'Individual',
-            'first_name' => 'Test',
-            'last_name' => 'Es',
-            'debug' => 1,
-        ) );
-        $this->contact_id = $results['id'];
-
-        $this->original_currency = 'EUR';
-        $this->original_amount = '1.23';
-        $this->gateway_txn_id = mt_rand();
-        $time = time();
-        $this->trxn_id = "TEST_GATEWAY {$this->gateway_txn_id} {$time}";
-
-        $this->setExchangeRates( $time, array( 'USD' => 1, 'EUR' => 0.5 ) );
-
-        $results = civicrm_api3( 'contribution', 'create', array(
-            'contact_id' => $this->contact_id,
-            'financial_type_id' => 'Cash',
-            'total_amount' => $this->original_amount,
-            'contribution_source' => $this->original_currency . ' ' . 
$this->original_amount,
-            'receive_date' => wmf_common_date_unix_to_civicrm( $time ),
-            'trxn_id' => $this->trxn_id,
-        ) );
-        $this->original_contribution_id = $results['id'];
-
-        $this->refund_contribution_id = null;
-    }
-
-    public function tearDown() {
-        civicrm_api3('contribution', 'delete', array(
-            'id' => $this->original_contribution_id,
-        ));
-
-        if ($this->refund_contribution_id && $this->refund_contribution_id != 
$this->original_contribution_id) {
-          civicrm_api3('contribution', 'delete', array(
-            'id' => $this->refund_contribution_id,
-          ));
-        }
-
-        civicrm_api3( 'contact', 'delete', array(
-            'id' => $this->contact_id,
-        ) );
-
-        parent::tearDown();
-    }
-
-    /**
-     * Check chargeback status exists.
-     */
-    public function testStatuses() {
-      $options = $this->callAPISuccess('Contribution', 'getoptions', 
array('field' => 'contribution_status_id'));
-      $this->assertTrue(in_array('Chargeback', $options['values']));
-    }
-
-    /**
-     * Covers wmf_civicrm_mark_refund.
-     */
-    public function testMarkRefund() {
-        wmf_civicrm_mark_refund( $this->original_contribution_id, 'refund', 
false, '2015-09-09', 'my_special_ref');
-
-        $contribution = civicrm_api3( 'contribution', 'getsingle', array(
-            'id' => $this->original_contribution_id,
-        ) );
-
-        $this->assertEquals( 'Refunded', $contribution['contribution_status'],
-            'Refunded contribution has correct status' );
-
-        $financialTransactions = civicrm_api3('EntityFinancialTrxn', 'get', 
array(
-            'entity_id' => $this->original_contribution_id,
-            'entity_table' => 'civicrm_contribution',
-            'api.financial_trxn.get' => 1,
-            'sequential' => TRUE,
-        ));
-        $this->assertEquals(2, $financialTransactions['count']);
-        $transaction1 = 
$financialTransactions['values']['0']['api.financial_trxn.get']['values'][0];
-        $transaction2 = 
$financialTransactions['values']['1']['api.financial_trxn.get']['values'][0];
-
-        $this->assertEquals($transaction1['trxn_id'], $this->trxn_id);
-        $this->assertEquals(strtotime($transaction2['trxn_date']), 
strtotime('2015-09-09'));
-        $this->assertEquals($transaction2['trxn_id'], 'my_special_ref');
-    }
-
-  /**
-   * Check that marking a contribution as refunded updates custom data 
appropriately.
-   */
-  public function testMarkRefundCheckCustomData() {
-    civicrm_api3('contribution', 'create', array(
-      'contact_id' => $this->contact_id,
-      'financial_type_id' => 'Cash',
-      'total_amount' => 50,
-      'contribution_source' => 'USD 50',
-      'receive_date' => '2014-11-01',
-    ));
-    // Create an additional negative contribution. This is how they were prior 
to Feb 2016.
-    // We want to check it is ignored for the purpose of determining the most 
recent donation
-    // although it should contribute to the lifetime total.
-    civicrm_api3('contribution', 'create', array(
-      'contact_id' => $this->contact_id,
-      'financial_type_id' => 'Cash',
-      'total_amount' => -10,
-      'contribution_source' => 'USD -10',
-      'receive_date' => '2015-12-01',
-    ));
-    wmf_civicrm_mark_refund( $this->original_contribution_id, 'refund', false, 
'2015-09-09', 'my_special_ref');
-    $contact = civicrm_api3('Contact', 'getsingle', array(
-      'id' => $this->contact_id,
-      'return' => array(
-        wmf_civicrm_get_custom_field_name('lifetime_usd_total'),
-        wmf_civicrm_get_custom_field_name('last_donation_date'),
-        wmf_civicrm_get_custom_field_name('last_donation_amount'),
-        wmf_civicrm_get_custom_field_name('last_donation_usd'),
-        wmf_civicrm_get_custom_field_name('is_2014_donor'),
-        wmf_civicrm_get_custom_field_name('is_' . date('Y') . '_donor'),
-        wmf_civicrm_get_custom_field_name('is_2015_donor'),
-      ),
-    ));
-    $this->assertEquals(40.00, 
$contact[wmf_civicrm_get_custom_field_name('lifetime_usd_total')]);
-    $this->assertEquals(50.00, 
$contact[wmf_civicrm_get_custom_field_name('last_donation_usd')]);
-    $this->assertEquals(50, 
$contact[wmf_civicrm_get_custom_field_name('last_donation_amount')]);
-    $this->assertEquals('2014-11-01 00:00:00', 
$contact[wmf_civicrm_get_custom_field_name('last_donation_date')]);
-    $this->assertEquals(TRUE, 
$contact[wmf_civicrm_get_custom_field_name('is_2014_donor')]);
-    $this->assertEquals(0, $contact[wmf_civicrm_get_custom_field_name('is_' . 
date('Y') . '_donor')]);
-    $this->assertEquals(0, 
$contact[wmf_civicrm_get_custom_field_name('is_2015_donor')]);
-  }
-
-
-  /**
-     * Make a refund with type set to "chargeback"
-     */
-    public function testMarkRefundWithType() {
-        $this->refund_contribution_id = wmf_civicrm_mark_refund( 
$this->original_contribution_id, 'chargeback' );
-
-        $contribution = civicrm_api3('contribution', 'getsingle', array(
-          'id' => $this->original_contribution_id,
-        ));
-
-        $this->assertEquals( 'Chargeback', 
$contribution['contribution_status'],
-            'Refund contribution has correct type' );
-    }
-
-    /**
-     * Make a refund for less than the original amount
-     */
-    public function testMakeLesserRefund() {
-        $lesser_amount = round( $this->original_amount - 0.25, 2 );
-        wmf_civicrm_mark_refund(
-            $this->original_contribution_id,
-            'chargeback',
-            true, null, null,
-            $this->original_currency, $lesser_amount
-        );
-
-
-        $this->refund_contribution_id  = CRM_Core_DAO::singleValueQuery("
-          SELECT entity_id FROM wmf_contribution_extra
-          WHERE
-          parent_contribution_id = %1",
-          array(1 => array($this->original_contribution_id, 'Integer'))
-        );
-
-        $refund_contribution = civicrm_api3('Contribution', 'getsingle', array(
-          'id' => $this->refund_contribution_id,
-        ));
-
-        $this->assertEquals(
-            "{$this->original_currency} 0.25",
-            $refund_contribution['contribution_source'],
-            'Refund contribution has correct lesser amount'
-        );
-    }
-
-    /**
-     * Make a refund in the wrong currency
-     *
-     * @expectedException WmfException
-     */
-    public function testMakeWrongCurrencyRefund() {
-        $wrong_currency = 'GBP';
-        $this->assertNotEquals( $this->original_currency, $wrong_currency );
-        wmf_civicrm_mark_refund(
-            $this->original_contribution_id, 'refund',
-            true, null, null,
-            $wrong_currency, $this->original_amount
-        );
-    }
-
-    /**
-     * Make a refund for too much.
-     */
-    public function testMakeScammerRefund() {
-        wmf_civicrm_mark_refund(
-            $this->original_contribution_id, 'refund',
-            true, null, null,
-            $this->original_currency, $this->original_amount + 100.00
-        );
-        $mailing = TestMailer::getMailing(0);
-        $this->assertContains("<p>Refund amount mismatch for : 
{$this->original_contribution_id}, difference is 100. See http", 
$mailing['html']);
-    }
-
-    /**
-     * Make a lesser refund in the wrong currency
-     */
-    public function testLesserWrongCurrencyRefund() {
-      $dbtime = '2000-04-03';
-      $epochtime = wmf_common_date_parse_string( $dbtime );
-      $this->setExchangeRates( $epochtime, array('COP' => .01 ) );
-
-      $result = $this->callAPISuccess('contribution', 'create', array(
-        'contact_id' => $this->contact_id,
-        'financial_type_id' => 'Cash',
-        'total_amount' => 200,
-        'contribution_source' => 'COP 20000',
-        'trxn_id' => "TEST_GATEWAY {$this->gateway_txn_id} " . (time() + 20),
-      ));
-
-      wmf_civicrm_mark_refund(
-        $result['id'],
-        'refund',
-        TRUE,
-        $dbtime,
-        NULL,
-        'COP',
-        5000
-      );
-
-      $contributions = $this->callAPISuccess('Contribution', 'get', array(
-        'contact_id' => $this->contact_id,
-        'sequential' => TRUE
-      ));
-      $this->assertEquals(3, $contributions['count'], print_r($contributions, 
TRUE));
-      $this->assertEquals(200, $contributions['values'][1]['total_amount']);
-      $this->assertEquals('USD', $contributions['values'][2]['currency']);
-      // Exchange rates might move a bit but hopefully it stays less than the 
original amount.
-      $this->assertEquals($contributions['values'][2]['total_amount'], 150);
-      $this->assertEquals('COP 15000', 
$contributions['values'][2]['contribution_source']);
-    }
-
-}
->>>>>>> BRANCH (d980aa Failmail can unpack multiple "to" addresses)
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 4f1d000..0000000
--- 
a/sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
+++ /dev/null
@@ -1,142 +0,0 @@
-<<<<<<< HEAD   (f138a2 Remove some tests from the deployment branch)
-=======
-<?php
-
-class BaseWmfDrupalPhpUnitTestCase extends PHPUnit_Framework_TestCase {
-    public function setUp() {
-        parent::setUp();
-
-        if ( !defined( 'DRUPAL_ROOT' ) ) {
-            throw new Exception( "Define DRUPAL_ROOT somewhere before running 
unit tests." );
-        }
-
-        global $user, $_exchange_rate_cache;
-        $_exchange_rate_cache = array();
-
-        $user = new stdClass();
-        $user->name = "foo_who";
-        $user->uid = "321";
-        $user->roles = array( DRUPAL_AUTHENTICATED_RID => 'authenticated user' 
);
-    }
-
-       /**
-        * 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);
-    }
-
-
-  /**
-   * 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 (d980aa Failmail can unpack multiple "to" addresses)
diff --git a/sites/all/modules/wmf_common/wmf_common.info 
b/sites/all/modules/wmf_common/wmf_common.info
index 78add7a..e4cbd17 100755
--- a/sites/all/modules/wmf_common/wmf_common.info
+++ b/sites/all/modules/wmf_common/wmf_common.info
@@ -8,8 +8,4 @@
 files[] = TransactionalWmfQueueConsumer.php
 files[] = WmfDatabase.php
 files[] = WmfException.php
-<<<<<<< HEAD   (f138a2 Remove some tests from the deployment branch)
-=======
 files[] = WmfQueueConsumer.php
-files[] = tests/include/BaseWmfDrupalPhpUnitTestCase.php
->>>>>>> BRANCH (d980aa Failmail can unpack multiple "to" addresses)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I085e0d7afb98fa126c4003d3bebe33971740a763
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: deployment
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

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

Reply via email to