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

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

Merge branch 'master' into deployment

33a0ccaa2 Fix failing refund test
502351898 clean up insert_contribution_tracking signature
b713a2a5a Add country to c_t rows created during imports
8266a273c Make mailing get process skip on exception.
105027eb0 Omnimail MailingProviderData.get: extend specificity on id.

Change-Id: I552ac1b1e768706bccc38d659f18946a6ef6d61c
---
D sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
D sites/all/modules/wmf_civicrm/tests/phpunit/RefundTest.php
D sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
3 files changed, 0 insertions(+), 667 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/15/369415/1

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 1c50940..0000000
--- 
a/sites/all/modules/recurring_globalcollect/tests/RecurringGlobalCollectTest.php
+++ /dev/null
@@ -1,216 +0,0 @@
-<<<<<<< HEAD   (23f2bb Merge branch 'master' into deployment)
-=======
-<?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'];
-               $tracking = array(
-                       'utm_source' => '..rcc',
-                       'utm_medium' => 'civicrm',
-                       'ts' => wmf_common_date_unix_to_sql( strtotime( 'now' ) 
),
-                       'contribution_id' => $result['id'],
-               );
-               wmf_civicrm_insert_contribution_tracking( $tracking );
-       }
-
-       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 (105027 Omnimail MailingProviderData.get: extend specificity on 
id.)
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 02a8529..0000000
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/RefundTest.php
+++ /dev/null
@@ -1,256 +0,0 @@
-<<<<<<< HEAD   (23f2bb Merge branch 'master' into deployment)
-=======
-<?php
-
-use wmf_communication\TestMailer;
-
-/**
- * @group Pipeline
- * @group WmfCivicrm
- * @group Refund
- */
-class RefundTest extends BaseWmfDrupalPhpUnitTestCase {
-
-    /**
-     * Id of the contribution created in the setup function.
-     *
-     * @var int
-     */
-    protected $original_contribution_id;
-    protected $gateway_txn_id;
-    protected $contact_id;
-    protected $original_currency;
-    protected $original_amount;
-    protected $trxn_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'];
-    }
-
-    public function tearDown() {
-        $this->cleanUpContact( $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() {
-        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
-        );
-
-
-        $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' => $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() {
-      $epochtime = time();
-      $dbtime = wmf_common_date_unix_to_civicrm( $epochtime );
-      $this->setExchangeRates( $epochtime, array('USD' => 1, 'COP' => .01 ) );
-
-      $result = $this->callAPISuccess('contribution', 'create', array(
-        'contact_id' => $this->contact_id,
-        'financial_type_id' => 'Cash',
-        'total_amount' => 200,
-        'currency' => 'USD',
-        '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']);
-      $this->assertEquals($contributions['values'][2]['total_amount'], 150);
-      $this->assertEquals('COP 15000', 
$contributions['values'][2]['contribution_source']);
-    }
-
-}
->>>>>>> BRANCH (105027 Omnimail MailingProviderData.get: extend specificity on 
id.)
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 af7640e..0000000
--- 
a/sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
+++ /dev/null
@@ -1,195 +0,0 @@
-<<<<<<< HEAD   (23f2bb Merge branch 'master' into deployment)
-=======
-<?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;
-  }
-
-  public function cleanUpContact( $contactId ) {
-    $contributions = $this->callAPISuccess('Contribution', 'get', array(
-      'contact_id' => $contactId
-    ) );
-    if ( !empty( $contributions['values'] ) ) {
-      foreach ( $contributions['values'] as $id => $details ) {
-        $this->callAPISuccess( 'Contribution', 'delete', array(
-          'id' => $id
-        ) );
-      }
-    }
-    $this->callAPISuccess('Contact', 'delete', array(
-      'id' => $contactId
-    ) );
-  }
-}
->>>>>>> BRANCH (105027 Omnimail MailingProviderData.get: extend specificity on 
id.)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I552ac1b1e768706bccc38d659f18946a6ef6d61c
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