Awight has uploaded a new change for review.

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

Change subject: WIP Test more fields during import
......................................................................

WIP Test more fields during import

Change-Id: Ibf19fb71e408bd8441d074321b39b60156685f87
---
M sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
1 file changed, 71 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/71/217971/1

diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
index 1d422f9..3dac40e 100644
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
+++ b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
@@ -25,6 +25,15 @@
         $api->Contact->Create( $contact_params );
         $this->contact_id = $api->id;
 
+        $contact_params = array(
+            'contact_type' => 'Organization',
+            'organization_name' => 'Test DAF',
+
+            'version' => 3,
+        );
+        $api->Contact->Create( $contact_params );
+        $this->daf_id = $api->id;
+
         $this->recur_amount = '1.23';
         $this->trxn_id = mt_rand();
         $this->time = time();
@@ -51,11 +60,12 @@
     }
 
     /**
-     * @XXX doesn't stupid work cos of member vars: dataProvider 
messageProvider
+     * FIXME: dataProvider messageProvider annotation doesn't stupid work it
+     * needs access to member vars...
      */
     public function testMessageInsert() {
         foreach ( $this->messageProvider() as $test ) {
-            list( $msg, $expected_contribution ) = $test;
+            list( $msg, $expected_contribution, 
$expected_contribution_custom_values ) = $test;
 
             // FIXME
             $this->run_random_id = mt_rand();
@@ -72,14 +82,23 @@
             $expected_contribution['trxn_id'] = 
$expected_transaction->get_unique_id();
             $this->stripTrxnIdTimestamp( $expected_contribution );
 
-            $this->stripUniques( $contribution );
+            $anonymized_contribution = $contribution;
+            $this->stripUniques( $anonymized_contribution );
 
-            // Strip contact_id if we are have no expectation
+            // Strip contact_id if we have no expectation.
             if ( empty( $expected_contribution['contact_id'] ) ) {
-                unset( $contribution['contact_id'] );
+                unset( $anonymized_contribution['contact_id'] );
             }
 
-            $this->assertEquals( $expected_contribution, $contribution );
+            $this->assertEquals( $expected_contribution, 
$anonymized_contribution );
+
+            if ( $expected_contribution_custom_values ) {
+                $actual_contribution_custom_values = 
wmf_civicrm_contribution_get_custom_values(
+                    $contribution['id'],
+                    array_keys( $expected_contribution_custom_values )
+                );
+                $this->assertEquals( $expected_contribution_custom_values, 
$actual_contribution_custom_values );
+            }
         }
     }
 
@@ -143,6 +162,7 @@
     function stripUniques( &$contribution ) {
         $isNumber = array(
             'id',
+            # FIXME: Why can't we pin down the date?
             'receive_date',
         );
         foreach ( $isNumber as $field ) {
@@ -165,8 +185,8 @@
         $payment_instrument_cc = wmf_civicrm_get_civi_id( 
'payment_instrument_id', 'Credit Card' );
 
         return array(
+            // Minimal contribution
             array(
-                // Normal contribution
                 array(
                     'email' => '[email protected]',
                     'gross' => '1.23',
@@ -199,6 +219,49 @@
                     'address_id' => '',
                     'check_number' => 'null',
                     'campaign_id' => '',
+                ),
+                array(),
+            ),
+
+            // Maximal contribution
+            array(
+                array(
+                    'email' => '[email protected]',
+                    'gross' => '1.23',
+                    'fee' => '0.03',
+                    'currency' => 'USD',
+                    'payment_method' => 'cc',
+                    'gateway' => 'test_gateway',
+                    'thankyou_date' => '2012-04-01',
+                ),
+                array(
+                    'contribution_type_id' => $contribution_type_cash,
+                    'contribution_page_id' => '',
+                    'payment_instrument_id' => $payment_instrument_cc,
+                    'non_deductible_amount' => '',
+                    'total_amount' => '1.23',
+                    'fee_amount' => '0.03',
+                    'net_amount' => '1.20',
+                    'invoice_id' => '',
+                    'currency' => 'USD',
+                    'cancel_date' => '',
+                    'cancel_reason' => '',
+                    'receipt_date' => '',
+                    'thankyou_date' => '20120401000000',
+                    'source' => 'USD 1.23',
+                    'amount_level' => '',
+                    'contribution_recur_id' => '',
+                    'honor_contact_id' => '',
+                    'is_test' => '',
+                    'is_pay_later' => '',
+                    'contribution_status_id' => '',
+                    'honor_type_id' => '',
+                    'address_id' => '',
+                    'check_number' => 'null',
+                    'campaign_id' => '',
+                ),
+                array(
+                    'gateway' => 'test_gateway',
                 ),
             ),
 
@@ -241,6 +304,7 @@
                     'check_number' => 'null',
                     'campaign_id' => '',
                 ),
+                array(),
             ),
         );
     }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf19fb71e408bd8441d074321b39b60156685f87
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to