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

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

Merge branch 'master' into deployment

and update vendor

46e0a30d1 Deal with sparse refund records in WX files
e780dfe61 Ensure civicrm_initialize() called

Change-Id: I3acfdc2420e0a2914c1abeae2e15edecef95f8bc
---
D sites/all/modules/wmf_audit/tests/IngenicoAuditTest.php
D 
sites/all/modules/wmf_audit/tests/data/Ingenico/sparseRefund/wx1.000000123420170828.010226.xml.gz
D sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
M vendor
4 files changed, 1 insertion(+), 420 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/92/374392/1

diff --git a/sites/all/modules/wmf_audit/tests/IngenicoAuditTest.php 
b/sites/all/modules/wmf_audit/tests/IngenicoAuditTest.php
deleted file mode 100644
index 4dfc78a..0000000
--- a/sites/all/modules/wmf_audit/tests/IngenicoAuditTest.php
+++ /dev/null
@@ -1,220 +0,0 @@
-<<<<<<< HEAD   (200f34 Merge branch 'master' into deployment)
-=======
-<?php
-
-/**
- * @group Ingenico
- * @group WmfAudit
- */
-class IngenicoAuditTest extends BaseWmfDrupalPhpUnitTestCase {
-       static protected $messages;
-
-       protected $contact_ids = array();
-       protected $contribution_ids = array();
-
-       public function setUp() {
-               parent::setUp();
-               self::$messages = array();
-
-               $dirs = array(
-                       'wmf_audit_log_archive_dir' => __DIR__ . '/data/logs/',
-                       'ingenico_audit_recon_completed_dir' => 
$this->getTempDir(),
-                       'ingenico_audit_working_log_dir' => $this->getTempDir(),
-               );
-
-               foreach ( $dirs as $var => $dir ) {
-                       if ( !is_dir( $dir ) ) {
-                               mkdir( $dir );
-                       }
-                       variable_set( $var, $dir );
-               }
-
-               $old_working = glob( $dirs['ingenico_audit_working_log_dir'] . 
'*' );
-               foreach ( $old_working as $zap ) {
-                       if ( is_file( $zap ) ) {
-                               unlink( $zap );
-                       }
-               }
-
-               variable_set( 'ingenico_audit_log_search_past_days', 7 );
-
-               // Fakedb doesn't fake the original txn for refunds, so add one 
here
-               $existing = wmf_civicrm_get_contributions_from_gateway_id( 
'globalcollect', '11992288' );
-               if ( $existing ) {
-                       // Previous test run may have crashed before cleaning up
-                       $contribution = $existing[0];
-               } else {
-                       $msg = array(
-                               'contribution_tracking_id' => 8675309,
-                               'currency' => 'USD',
-                               'date' => 1455825706,
-                               'email' => 'n...@flying.com',
-                               'gateway' => 'globalcollect',
-                               'gateway_txn_id' => '11992288',
-                               'gross' => 100.00,
-                               'payment_method' => 'cc',
-                               'payment_submethod' => 'visa',
-                       );
-                       $contribution = 
wmf_civicrm_contribution_message_import( $msg );
-               }
-               $this->contact_ids[] = $contribution['contact_id'];
-
-               // and another for the chargeback
-               $existing = wmf_civicrm_get_contributions_from_gateway_id( 
'globalcollect', '55500002' );
-               if ( $existing ) {
-                       // Previous test run may have crashed before cleaning up
-                       $contribution = $existing[0];
-               } else {
-                       $msg = array(
-                               'contribution_tracking_id' => 5318008,
-                               'currency' => 'USD',
-                               'date' => 1443724034,
-                               'email' => 'lovelys...@python.com',
-                               'gateway' => 'globalcollect',
-                               'gateway_txn_id' => '55500002',
-                               'gross' => 200.00,
-                               'payment_method' => 'cc',
-                               'payment_submethod' => 'visa',
-                       );
-                       $contribution = 
wmf_civicrm_contribution_message_import( $msg );
-               }
-               $this->contact_ids[] = $contribution['contact_id'];
-
-               // and another for the sparse refund
-               $this->setExchangeRates( 1443724034, array( 'EUR' => 1.5, 'USD' 
=> 1 ) );
-               $existing = wmf_civicrm_get_contributions_from_gateway_id( 
'globalcollect', '1111662235' );
-               if ( $existing ) {
-                       // Previous test run may have crashed before cleaning up
-                       $contribution = $existing[0];
-               } else {
-                       db_merge( 'contribution_tracking' )->key( array(
-                               'id' => 48987654
-                       ) )->fields( array(
-                               'country' => 'IT',
-                               'utm_source' => 'something',
-                               'utm_medium' => 'another_thing',
-                               'utm_campaign' => 'campaign_thing',
-                               'language' => 'it'
-                       ) )->execute();
-                       $msg = array(
-                               'contribution_tracking_id' => 48987654,
-                               'currency' => 'EUR',
-                               'date' => 1443724034,
-                               'email' => 'lovelys...@python.com',
-                               'gateway' => 'globalcollect',
-                               'gateway_txn_id' => '1111662235',
-                               'gross' => 15.00,
-                               'payment_method' => 'cc',
-                               'payment_submethod' => 'visa',
-                       );
-                       $contribution = 
wmf_civicrm_contribution_message_import( $msg );
-               }
-               $this->contact_ids[] = $contribution['contact_id'];
-       }
-
-       public function tearDown() {
-               foreach( $this->contact_ids as $contact_id ) {
-                       $this->cleanUpContact( $contact_id );
-               }
-       }
-
-       public function auditTestProvider() {
-               return array(
-                       array( __DIR__ . '/data/Ingenico/donation/', array(
-                               'main' => array(
-                                       array(
-                                               'contribution_tracking_id' => 
'5551212',
-                                               'country' => 'US',
-                                               'currency' => 'USD',
-                                               'date' => 1501368968,
-                                               'email' => 
'dutch...@flying.net',
-                                               'first_name' => 'Arthur',
-                                               'gateway' => 'globalcollect', 
// TODO: Connect donations get 'ingenico'
-                                               'gateway_txn_id' => '987654321',
-                                               'gross' => '3.00',
-                                               'installment' => 1,
-                                               'last_name' => 'Aardvark',
-                                               'order_id' => '987654321',
-                                               'payment_method' => 'cc',
-                                               'payment_submethod' => 'visa',
-                                               'user_ip' => '111.222.33.44',
-                                               'utm_campaign' => 
'ingenico_audit',
-                                               'utm_medium' => 
'ingenico_audit',
-                                               'utm_source' => 
'ingenico_audit',
-                                               'street_address' => '1111 Fake 
St',
-                                               'city' => 'Denver',
-                                               'state_province' => 'CO',
-                                               'postal_code' => '87654',
-                                       ),
-                               ),
-                       ) ),
-                       array( __DIR__ . '/data/Ingenico/refund/', array(
-                               'negative' => array(
-                                       array(
-                                               'date' => 1500942220,
-                                               'gateway' => 'globalcollect',
-                                               'gateway_parent_id' => 
'11992288',
-                                               'gateway_refund_id' => 
'11992288',
-                                               'gross' => '100.00',
-                                               'gross_currency' => 'USD',
-                                               'type' => 'refund',
-                                       ),
-                               ),
-                       ) ),
-                       array( __DIR__ . '/data/Ingenico/sparseRefund/', array(
-                               'negative' => array(
-                                       array(
-                                               'date' => 1503964800,
-                                               'gateway' => 'globalcollect',
-                                               'gateway_parent_id' => 
'1111662235',
-                                               'gateway_refund_id' => 
'1111662235',
-                                               'gross' => '15.00',
-                                               'gross_currency' => 'EUR',
-                                               'type' => 'refund',
-                                       ),
-                               ),
-                       ) ),
-                       array( __DIR__ . '/data/Ingenico/chargeback/', array(
-                               'negative' => array(
-                                       array(
-                                               'date' => 1495023569,
-                                               'gateway' => 'globalcollect',
-                                               'gateway_parent_id' => 
'55500002',
-                                               'gateway_refund_id' => 
'55500002',
-                                               'gross' => '200.00',
-                                               'gross_currency' => 'USD',
-                                               'type' => 'chargeback',
-                                       ),
-                               ),
-                       ) ),
-               );
-       }
-
-       /**
-        * @dataProvider auditTestProvider
-        */
-       public function testParseFiles( $path, $expectedMessages ) {
-               variable_set( 'ingenico_audit_recon_files_dir', $path );
-
-               $this->runAuditor();
-
-               $this->assertEquals( $expectedMessages, self::$messages );
-       }
-
-       protected function runAuditor() {
-               $options = array(
-                       'fakedb' => true,
-                       'quiet' => true,
-                       'test' => true,
-                       'test_callback' => array( 'IngenicoAuditTest', 
'receiveMessages' ),
-                       #'verbose' => 'true', # Uncomment to debug.
-               );
-               $audit = new IngenicoAuditProcessor( $options );
-               $audit->run();
-       }
-
-       static public function receiveMessages( $msg, $type ) {
-               self::$messages[$type][] = $msg;
-       }
-}
->>>>>>> BRANCH (e780df Ensure civicrm_initialize() called)
diff --git 
a/sites/all/modules/wmf_audit/tests/data/Ingenico/sparseRefund/wx1.000000123420170828.010226.xml.gz
 
b/sites/all/modules/wmf_audit/tests/data/Ingenico/sparseRefund/wx1.000000123420170828.010226.xml.gz
deleted file mode 100644
index 0b29176..0000000
--- 
a/sites/all/modules/wmf_audit/tests/data/Ingenico/sparseRefund/wx1.000000123420170828.010226.xml.gz
+++ /dev/null
Binary files differ
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 f3cafeb..0000000
--- 
a/sites/all/modules/wmf_common/tests/includes/BaseWmfDrupalPhpUnitTestCase.php
+++ /dev/null
@@ -1,199 +0,0 @@
-<<<<<<< HEAD   (200f34 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
-        ) );
-
-        db_delete( 'contribution_tracking' )
-          ->condition( 'contribution_id', $id )
-          ->execute();
-      }
-    }
-    $this->callAPISuccess('Contact', 'delete', array(
-      'id' => $contactId
-    ) );
-  }
-}
->>>>>>> BRANCH (e780df Ensure civicrm_initialize() called)
diff --git a/vendor b/vendor
index 7b0c431..b51e1d5 160000
--- a/vendor
+++ b/vendor
@@ -1 +1 @@
-Subproject commit 7b0c431fb3e1f103aba63f4bdd3dce67d1c95bad
+Subproject commit b51e1d53ea105a347fa0731bf8b4f339c3b005ca

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

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