[MediaWiki-commits] [Gerrit] wikimedia...crm[master]: Only store the full country code if it is on our valid list.

2016-09-21 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Only store the full country code if it is on our valid list.
..


Only store the full country code if it is on our valid list.

If the country code is not on the list then prefer the 2 digit code. This means 
'en' is better than 'en_NO
(Norwegian English). Separately we will look to remove the invalid options we 
already have in our DB.

If neither are valid store the full thing to make it easier to find them

Bug: T96410
Change-Id: Ie7e8a958c2496a738ce738dd827b7ed04b2d9fbd
---
M sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
2 files changed, 124 insertions(+), 32 deletions(-)

Approvals:
  Ejegg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
index c3ad868..86e8901 100644
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
+++ b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
@@ -103,7 +103,6 @@
 'return' => 'name',
 )), $expected['contact'][$renamedField]);
 }
-
 }
 
 if ( !empty( $expected['contact_custom_values'] ) ) {
@@ -141,35 +140,7 @@
 'payment_method' => 'cc',
 ),
 array(
-'contribution' => array(
-'address_id' => '',
-'amount_level' => '',
-'campaign_id' => '',
-'cancel_date' => '',
-'cancel_reason' => '',
-'check_number' => '',
-'contribution_page_id' => '',
-'contribution_recur_id' => '',
-'contribution_status_id' => '1',
-'contribution_type_id' => $contribution_type_cash,
-'currency' => 'USD',
-'fee_amount' => '0',
-'invoice_id' => '',
-'is_pay_later' => '',
-'is_test' => '',
-'net_amount' => '1.23',
-'non_deductible_amount' => '',
-'payment_instrument_id' => $payment_instrument_cc,
-'receipt_date' => '',
-'receive_date' => '2012050100',
-'source' => 'USD 1.23',
-'thankyou_date' => '',
-'total_amount' => '1.23',
-'trxn_id' => "TEST_GATEWAY {$gateway_txn_id}",
-'financial_type_id' => $contribution_type_cash,
-'creditnote_id' => '',
-'tax_amount' => '',
-),
+'contribution' => 
$this->getBaseContribution($gateway_txn_id),
 ),
 ),
 
@@ -219,6 +190,7 @@
 'email' => 'nob...@wikimedia.org',
 'first_name' => 'First',
 'fee' => '0.03',
+'preferred_language' => 'en_US',
 'gateway' => 'test_gateway',
 'gateway_txn_id' => $gateway_txn_id,
 'gift_source' => 'Legacy Gift',
@@ -246,6 +218,7 @@
 'middle_name' => 'Middle',
 'prefix' => $new_prefix,
 'suffix' => 'Sr.',
+'preferred_language' => 'en_US',
 ),
 'contribution' => array(
 'address_id' => '',
@@ -296,8 +269,57 @@
 ),
 ),
 ),
+  // Invalid language suffix for valid short lang.
+  'invalid language suffix' => array(
+array(
+  'currency' => 'USD',
+  'date' => '2012-05-01 00:00:00',
+  'email' => 'nob...@wikimedia.org',
+  'gateway' => 'test_gateway',
+  'gateway_txn_id' => $gateway_txn_id,
+  'gross' => '1.23',
+  'payment_method' => 'cc',
+  'preferred_language' => 'en_ZZ',
+  'name_prefix' => $new_prefix,
+  'name_suffix' => 'Sr.',
+),
+array(
+  'contact' => array(
+'preferred_language' => 'en',
+'prefix' => $new_prefix,
+'suffix' => 'Sr.',
+  ),
+  'contribution' => $this->getBaseContribution($gateway_txn_id),
+),
+  ),
 
-// Organization contribution
+  // Invalid language suffix for invalid short lang.
+  'invalid short language' => array(
+array(
+ 

[MediaWiki-commits] [Gerrit] wikimedia...crm[master]: Only store the full country code if it is on our valid list.

2016-09-14 Thread Eileen (Code Review)
Eileen has uploaded a new change for review.

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

Change subject: Only store the full country code if it is on our valid list.
..

Only store the full country code if it is on our valid list.

If the country code is not on the list then prefer the 2 digit code. This means 
'en' is better than 'en_NO
(Norwegian English). Separately we will look to remove the invalid options we 
already have in our DB.

If neither are valid store the full thing to make it easier to find them

Bug: T96410
Change-Id: Ie7e8a958c2496a738ce738dd827b7ed04b2d9fbd
---
M sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
2 files changed, 124 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/32/310732/1

diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
index c3ad868..86e8901 100644
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
+++ b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
@@ -103,7 +103,6 @@
 'return' => 'name',
 )), $expected['contact'][$renamedField]);
 }
-
 }
 
 if ( !empty( $expected['contact_custom_values'] ) ) {
@@ -141,35 +140,7 @@
 'payment_method' => 'cc',
 ),
 array(
-'contribution' => array(
-'address_id' => '',
-'amount_level' => '',
-'campaign_id' => '',
-'cancel_date' => '',
-'cancel_reason' => '',
-'check_number' => '',
-'contribution_page_id' => '',
-'contribution_recur_id' => '',
-'contribution_status_id' => '1',
-'contribution_type_id' => $contribution_type_cash,
-'currency' => 'USD',
-'fee_amount' => '0',
-'invoice_id' => '',
-'is_pay_later' => '',
-'is_test' => '',
-'net_amount' => '1.23',
-'non_deductible_amount' => '',
-'payment_instrument_id' => $payment_instrument_cc,
-'receipt_date' => '',
-'receive_date' => '2012050100',
-'source' => 'USD 1.23',
-'thankyou_date' => '',
-'total_amount' => '1.23',
-'trxn_id' => "TEST_GATEWAY {$gateway_txn_id}",
-'financial_type_id' => $contribution_type_cash,
-'creditnote_id' => '',
-'tax_amount' => '',
-),
+'contribution' => 
$this->getBaseContribution($gateway_txn_id),
 ),
 ),
 
@@ -219,6 +190,7 @@
 'email' => 'nob...@wikimedia.org',
 'first_name' => 'First',
 'fee' => '0.03',
+'preferred_language' => 'en_US',
 'gateway' => 'test_gateway',
 'gateway_txn_id' => $gateway_txn_id,
 'gift_source' => 'Legacy Gift',
@@ -246,6 +218,7 @@
 'middle_name' => 'Middle',
 'prefix' => $new_prefix,
 'suffix' => 'Sr.',
+'preferred_language' => 'en_US',
 ),
 'contribution' => array(
 'address_id' => '',
@@ -296,8 +269,57 @@
 ),
 ),
 ),
+  // Invalid language suffix for valid short lang.
+  'invalid language suffix' => array(
+array(
+  'currency' => 'USD',
+  'date' => '2012-05-01 00:00:00',
+  'email' => 'nob...@wikimedia.org',
+  'gateway' => 'test_gateway',
+  'gateway_txn_id' => $gateway_txn_id,
+  'gross' => '1.23',
+  'payment_method' => 'cc',
+  'preferred_language' => 'en_ZZ',
+  'name_prefix' => $new_prefix,
+  'name_suffix' => 'Sr.',
+),
+array(
+  'contact' => array(
+'preferred_language' => 'en',
+'prefix' => $new_prefix,
+'suffix' => 'Sr.',
+  ),
+  'contribution' => $this->getBaseContribution($gateway_txn_id),
+),
+  ),
 
-// Organization contribution
+  // Invalid language suffix for invalid short lang.
+  'invalid