jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/349253 )
Change subject: Delete old PP-specific normalization
......................................................................
Delete old PP-specific normalization
Now happens upstream.
Switch over all tests to use normalized messages.
Also improve test teardown.
Change-Id: I311643d40cb3503f95abb18291fbd871091c333e
---
M sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
M sites/all/modules/queue2civicrm/tests/data/recurring_payment.json
M sites/all/modules/queue2civicrm/tests/data/recurring_signup.json
D sites/all/modules/queue2civicrm/tests/data/subscr_payment_normalized.json
D sites/all/modules/queue2civicrm/tests/data/subscr_signup_normalized.json
M sites/all/modules/queue2civicrm/tests/includes/Message.php
M sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
7 files changed, 104 insertions(+), 397 deletions(-)
Approvals:
Cdentinger: Looks good to me, approved
jenkins-bot: Verified
diff --git
a/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
b/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
index b37b404..851e40c 100644
--- a/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
+++ b/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
@@ -84,11 +84,6 @@
// should not require special normalization
} else if ( !isset( $msg[ 'contribution_tracking_id' ]) ) {
$msg_normalized[ 'contribution_tracking_id' ] =
recurring_get_contribution_tracking_id( $msg );
- // TODO: remove this after deploying audit and IPN
updates to do message normalization there
- if ( isset( $msg['payer_email'] ) ) {
- // This is an old-school non-normalized PayPal
message.
- $msg = $this->normalizePaypalMessage( $msg );
- }
} else {
$msg['contribution_tracking_update'] = false;
}
@@ -104,174 +99,6 @@
$msg = wmf_civicrm_normalize_msg( $msg );
return $msg;
- }
-
- /**
- * Normalize raw PayPal message
- *
- * It is possible that we'll get a raw message from PayPal. If that is
the
- * case, this will convert the raw PayPal message to our normalized
format.
- *
- * This is large and unwieldy.
- *
- * FIXME: move this normalization into the paypal listener
- *
- * @param $msg
- * @return array
- */
- protected function normalizePaypalMessage( $msg ) {
- $msg_normalized = array();
-
- if ( isset( $msg['payment_date'] ) ) {
- $msg_normalized['date'] = strtotime(
$msg['payment_date'] );
- }
-
- // the subscription id
- $msg_normalized[ 'subscr_id' ] = $msg[ 'subscr_id' ];
- $msg_normalized[ 'txn_type' ] = $msg[ 'txn_type' ];
- $msg_normalized[ 'email' ] = $msg[ 'payer_email' ];
-
- // Premium info
- if ( isset( $msg[ 'option_selection1' ] ) && !is_numeric( $msg[
'option_selection1' ] ) ) {
- $msg_normalized[ 'size' ] = $msg[ 'option_selection1' ];
- $msg_normalized[ 'premium_language' ] = $msg[
'option_selection2' ];
- }
-
- // Contact info
- if ( $msg[ 'txn_type' ] == 'subscr_signup' || $msg[ 'txn_type'
] == 'subscr_payment' || $msg[ 'txn_type' ] == 'subscr_modify' ) {
- $msg_normalized[ 'first_name' ] = $msg[ 'first_name' ];
- $msg_normalized[ 'middle_name' ] = '';
- $msg_normalized[ 'last_name' ] = $msg[ 'last_name' ];
-
- if ( isset( $msg['address_street'] ) ) {
- $split = explode("\n", str_replace("\r", '',
$msg[ 'address_street' ]));
- $msg_normalized[ 'street_address' ] = $split[0];
- if ( count( $split ) > 1 ) {
- $msg_normalized[
'supplemental_address_1' ] = $split[1];
- }
- $msg_normalized[ 'city' ] = $msg[
'address_city' ];
- $msg_normalized[ 'state_province' ] = $msg[
'address_state' ];
- $msg_normalized[ 'country' ] = $msg[
'address_country_code' ];
- $msg_normalized[ 'postal_code' ] = $msg[
'address_zip' ];
-
- // Shipping info (address same as above since
PayPal only passes 1 address)
- $split = explode(" ", $msg[ 'address_name' ]);
- $msg_normalized[ 'last_name_2' ] =
array_pop($split);
- $msg_normalized[ 'first_name_2' ] = implode("
", $split);
- $split = explode("\n", str_replace("\r", '',
$msg[ 'address_street' ]));
- $msg_normalized[ 'street_address_2' ] =
$split[0];
- if ( count( $split ) > 1 ) {
- $msg_normalized[
'supplemental_address_2' ] = $split[1];
- }
- } elseif ( isset( $msg['residence_country'] ) ) {
- $msg_normalized['country'] =
$msg['residence_country'];
- }
- }
-
- // payment-specific message handling
- if ( $msg[ 'txn_type' ] == 'subscr_payment' ) {
- // default to not update contribution tracking data
- $msg_normalized[ 'contribution_tracking_update' ] =
false;
-
- // get the database connection to the tracking table
- $dbs = wmf_civicrm_get_dbs();
- $dbs->push( 'donations' );
- $query = "SELECT * FROM {contribution_tracking} WHERE
id = :id";
- $tracking_data = db_query( $query, array( ':id' =>
$msg[ 'custom' ] ) )->fetchAssoc();
- if ( $tracking_data ) {
- // if we don't have a contribution id in the
tracking data, we need to update
- if ( !$tracking_data[ 'contribution_id' ] ||
!is_numeric( $tracking_data[ 'contribution_id' ] ) ) {
- $msg_normalized[
'contribution_tracking_update' ] = true;
- $msg_normalized[ 'optout' ] =
$tracking_data[ 'optout' ];
- $msg_normalized[ 'anonymous' ] =
$tracking_data[ 'anonymous' ];
- $msg_normalized[ 'comment' ] =
$tracking_data[ 'note' ];
- }
- } else {
- watchdog( 'recurring', "There is no
contribution tracking id associated with this message.", array(),
WATCHDOG_NOTICE );
- }
-
- $msg_normalized[ 'gateway_txn_id' ] = $msg[ 'txn_id' ];
- $msg_normalized[ 'currency' ] = $msg[ 'mc_currency' ];
- $msg_normalized[ 'gross' ] = $msg[ 'mc_gross' ];
- $msg_normalized[ 'fee' ] = $msg[ 'mc_fee' ];
- $msg_normalized[ 'gross' ] = $msg[ 'mc_gross' ];
- $msg_normalized[ 'net' ] = $msg_normalized[ 'gross' ] -
$msg_normalized[ 'fee' ];
- $msg_normalized[ 'payment_date' ] = strtotime( $msg[
'payment_date' ] );
- } else {
-
- // break the period out for civicrm
- if( isset( $msg[ 'period3' ] ) ) {
- // map paypal period unit to civicrm period
units
- $period_map = array(
- 'm' => 'month',
- 'd' => 'day',
- 'w' => 'week',
- 'y' => 'year',
- );
-
- $period = explode( " ", $msg[ 'period3' ] );
- $msg_normalized[ 'frequency_interval' ] =
$period[0];
- $msg_normalized[ 'frequency_unit' ] =
$period_map[ strtolower( $period[1] ) ];
- }
-
- if ( isset( $msg[ 'recur_times' ] ) ) {
- $msg_normalized[ 'installments' ] = $msg[
'recur_times' ];
- } else {
- // forever
- $msg_normalized[ 'installments' ] = 0;
- }
-
- if ( isset( $msg[ 'amount3' ] ) ) {
- $msg_normalized[ 'gross' ] = $msg[ 'amount3' ];
- } elseif ( isset( $msg[ 'mc_amount3' ] ) ) {
- $msg_normalized[ 'gross' ] = $msg[ 'mc_amount3'
];
- }
-
- if ( isset( $msg['mc_currency'] ) ) {
- $msg_normalized[ 'currency' ] = $msg[
'mc_currency' ];
- }
-
- if ( isset( $msg[ 'subscr_date' ] ) ) {
- if ( $msg[ 'txn_type' ] == 'subscr_signup' ) {
- $msg_normalized[ 'create_date' ] =
strtotime( $msg[ 'subscr_date' ] );
- $msg_normalized[ 'start_date' ] =
strtotime( $msg[ 'subscr_date' ] );
- } elseif( $msg[ 'txn_type' ] == 'subscr_cancel'
) {
- $msg_normalized[ 'cancel_date' ] =
strtotime( $msg[ 'subscr_date' ] );
- }
- if ( !isset( $msg_normalized['date'] ) ) {
- $msg_normalized['date'] = strtotime(
$msg['subscr_date'] );
- }
- }
-
- if ( $msg[ 'txn_type' ] == 'subscr_modify' ) {
- $msg_normalized[ 'modified_date' ] = $msg[
'subscr_effective' ];
- }
-
- if ( $msg[ 'txn_type' ] == 'subscr_failed' ) {
- $recur_record = wmf_civicrm_get_recur_record(
$msg[ 'subscr_id' ] );
- $msg_normalized[ 'failure_count' ] =
$recur_record->failure_count + 1;
- if ( isset( $msg[ 'retry_at' ] )) {
- $msg_normalized[ 'failure_retry_date' ]
= strtotime( $msg[ 'retry_at' ] );
- } elseif( isset( $msg[ 'failure_retry_date' ]
)) {
- $msg_normalized[ 'failure_retry_date' ]
= strtotime( $msg[ 'failure_retry_date' ] );
- }
- }
- }
-
- $msg_normalized[ 'gateway' ] = ( !empty( $msg['gateway'] ) ?
$msg['gateway'] : 'paypal' );
-
- if ( !isset( $msg_normalized['date'] ) ) {
- $msg_normalized['date'] = time();
- }
-
- // FIXME: so dirty.
- foreach ( $msg as $key => $value ) {
- if ( strpos( $key, "source_" ) === 0 ) {
- $msg_normalized[$key] = $value;
- }
- }
-
- return $msg_normalized;
}
/**
diff --git a/sites/all/modules/queue2civicrm/tests/data/recurring_payment.json
b/sites/all/modules/queue2civicrm/tests/data/recurring_payment.json
index b71331f..e513314 100644
--- a/sites/all/modules/queue2civicrm/tests/data/recurring_payment.json
+++ b/sites/all/modules/queue2civicrm/tests/data/recurring_payment.json
@@ -1,40 +1,22 @@
{
- "address_city": "Edmonton",
- "address_country": "Canada",
- "address_country_code": "CA",
- "address_name": "Gen Russ",
- "address_state": "Alberta",
- "address_status": "confirmed",
- "address_street": "1211122 132 st",
- "address_zip": "T4V 2L2",
- "business": "[email protected]",
- "charset": "UTF-8",
- "custom": "15017277",
- "first_name": "Gen",
- "gateway": "paypal",
- "ipn_track_id": "aab364ce13499",
- "item_name": "Donation to the Wikimedia Foundation",
- "item_number": "DONATE",
- "last_name": "Russ",
- "mc_currency": "CAD",
- "mc_fee": "0.33",
- "mc_gross": "3.00",
- "notify_version": "3.7",
- "payer_email": "[email protected]",
- "payer_id": "24B4Y6BZGNT2C",
- "payer_status": "unverified",
- "payment_date": "15:52:33 Nov 01, 2013 PDT",
- "payment_fee": "",
- "payment_gross": "",
- "payment_status": "Completed",
- "payment_type": "instant",
- "protection_eligibility": "Eligible",
- "receiver_email": "[email protected]",
- "receiver_id": "EZ782AEXJUWU8",
- "recurring": 1,
- "residence_country": "CA",
- "subscr_id": "S-64E67934881J88118",
- "transaction_subject": "15201777",
+ "date": 1383346353,
+ "subscr_id": null,
"txn_type": "subscr_payment",
- "verify_sign": "AMuUaVWl4LgJrwIOMczIBpnrLrrZAkmsqzN5PHvG6cUBxLoeCb475B8V"
+ "contribution_tracking_id": "15017277",
+ "email": "[email protected]",
+ "first_name": "Gen",
+ "middle_name": "",
+ "last_name": "Russ",
+ "street_address": "1211122 132 st",
+ "city": "Edmonton",
+ "state_province": "Alberta",
+ "country": "CA",
+ "postal_code": "T4V 2L2",
+ "gateway_txn_id": 1765009520,
+ "currency": "CAD",
+ "gross": "3.00",
+ "fee": "0.33",
+ "net": 2.67,
+ "gateway": "paypal",
+ "recurring": true
}
diff --git a/sites/all/modules/queue2civicrm/tests/data/recurring_signup.json
b/sites/all/modules/queue2civicrm/tests/data/recurring_signup.json
index 9642c21..cc512f6 100644
--- a/sites/all/modules/queue2civicrm/tests/data/recurring_signup.json
+++ b/sites/all/modules/queue2civicrm/tests/data/recurring_signup.json
@@ -1,35 +1,24 @@
{
- "address_city": "Bethel Park",
- "address_country_code": "US",
- "address_country": "United States",
- "address_name": "Gen Russ",
- "address_state": "PA",
- "address_status": "confirmed",
- "address_street": "5109 Lockwood Rd",
- "address_zip": "15110-1232",
- "amount3": "3.00",
- "business": "[email protected]",
- "charset": "UTF-8",
- "custom": "15028173",
- "first_name": "Gen D",
+ "subscr_id": 2048343366,
+ "txn_type": "subscr_signup",
+ "contribution_tracking_id": "15028173",
+ "email": "[email protected]",
+ "first_name": "Gen D",
+ "middle_name": "",
+ "last_name": "Russ",
+ "street_address": "5109 Lockwood Rd",
+ "city": "Bethel Park",
+ "state_province": "PA",
+ "country": "US",
+ "postal_code": "15110-1232",
+ "frequency_interval": "1",
+ "frequency_unit": "month",
+ "installments": 0,
+ "gross": "3.00",
+ "currency": "CAD",
+ "create_date": 1383347225,
+ "start_date": 1383347225,
+ "date": 1383347225,
"gateway": "paypal",
- "ipn_track_id": "38c689188774d",
- "item_name": "Donation to the Wikimedia Foundation",
- "item_number": "DONATE",
- "last_name": "Russ",
- "mc_amount3": "3.00",
- "mc_currency": "CAD",
- "notify_version": "3.7",
- "payer_email": "[email protected]",
- "payer_id": "HK88M82Y7MLZ2",
- "payer_status": "verified",
- "period3": "1 M",
- "reattempt": "1",
- "receiver_email": "[email protected]",
- "recurring": "1",
- "residence_country": "US",
- "subscr_date": "16:07:05 Nov 01, 2013 PDT",
- "subscr_id": "S-1028048X07A26702A",
- "txn_type": "subscr_signup",
- "verify_sign": "A5VSEChOEYwkDv7mgId.m2eXJO5RAhH.qwB5AejTaUrPjcw9JvEAv2S0"
+ "recurring": true
}
diff --git
a/sites/all/modules/queue2civicrm/tests/data/subscr_payment_normalized.json
b/sites/all/modules/queue2civicrm/tests/data/subscr_payment_normalized.json
deleted file mode 100644
index e513314..0000000
--- a/sites/all/modules/queue2civicrm/tests/data/subscr_payment_normalized.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "date": 1383346353,
- "subscr_id": null,
- "txn_type": "subscr_payment",
- "contribution_tracking_id": "15017277",
- "email": "[email protected]",
- "first_name": "Gen",
- "middle_name": "",
- "last_name": "Russ",
- "street_address": "1211122 132 st",
- "city": "Edmonton",
- "state_province": "Alberta",
- "country": "CA",
- "postal_code": "T4V 2L2",
- "gateway_txn_id": 1765009520,
- "currency": "CAD",
- "gross": "3.00",
- "fee": "0.33",
- "net": 2.67,
- "gateway": "paypal",
- "recurring": true
-}
diff --git
a/sites/all/modules/queue2civicrm/tests/data/subscr_signup_normalized.json
b/sites/all/modules/queue2civicrm/tests/data/subscr_signup_normalized.json
deleted file mode 100644
index cc512f6..0000000
--- a/sites/all/modules/queue2civicrm/tests/data/subscr_signup_normalized.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "subscr_id": 2048343366,
- "txn_type": "subscr_signup",
- "contribution_tracking_id": "15028173",
- "email": "[email protected]",
- "first_name": "Gen D",
- "middle_name": "",
- "last_name": "Russ",
- "street_address": "5109 Lockwood Rd",
- "city": "Bethel Park",
- "state_province": "PA",
- "country": "US",
- "postal_code": "15110-1232",
- "frequency_interval": "1",
- "frequency_unit": "month",
- "installments": 0,
- "gross": "3.00",
- "currency": "CAD",
- "create_date": 1383347225,
- "start_date": 1383347225,
- "date": 1383347225,
- "gateway": "paypal",
- "recurring": true
-}
diff --git a/sites/all/modules/queue2civicrm/tests/includes/Message.php
b/sites/all/modules/queue2civicrm/tests/includes/Message.php
index c1d46dd..6494016 100644
--- a/sites/all/modules/queue2civicrm/tests/includes/Message.php
+++ b/sites/all/modules/queue2civicrm/tests/includes/Message.php
@@ -135,20 +135,10 @@
function __construct( $values = array() ) {
$this->loadDefaults( "recurring_payment" );
- $this->txn_id_key = 'txn_id';
+ $this->txn_id_key = 'gateway_txn_id';
parent::__construct( $values );
}
-}
-
-class NormalizedSubscriptionPaymentMessage extends TransactionMessage {
- function __construct( $values = array() ) {
- $this->loadDefaults( "subscr_payment_normalized" );
-
- $this->txn_id_key = 'gateway_txn_id';
-
- parent::__construct( $values );
- }
}
class RecurringSignupMessage extends TransactionMessage {
@@ -157,14 +147,6 @@
parent::__construct( $values );
}
-}
-
-class NormalizedRecurringSignupMessage extends TransactionMessage {
- function __construct( $values = array() ) {
- $this->loadDefaults( "subscr_signup_normalized" );
-
- parent::__construct( $values );
- }
}
/**
diff --git
a/sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
b/sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
index 67328e1..88f3f02 100644
--- a/sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
+++ b/sites/all/modules/queue2civicrm/tests/phpunit/RecurringQueueTest.php
@@ -13,6 +13,9 @@
*/
protected $consumer;
+ protected $contributions = array();
+ protected $ctIds = array();
+
public function setUp() {
parent::setUp();
$config = TestingSmashPigDbQueueConfiguration::instance();
@@ -24,6 +27,52 @@
);
}
+ // TODO: other queue import tests need to clean up like this!
+ public function tearDown() {
+ foreach ( $this->ctIds as $ctId ) {
+ db_delete( 'contribution_tracking' )
+ ->condition( 'id', $ctId )
+ ->execute();
+ }
+ foreach( $this->contributions as $contribution ) {
+ CRM_Core_DAO::executeQuery(
+ "
+ DELETE FROM civicrm_contribution
+ WHERE id = %1",
+ array( 1 => array( $contribution['id'],
'Positive' ) )
+ );
+ CRM_Core_DAO::executeQuery(
+ "
+ DELETE FROM civicrm_contact
+ WHERE id = %1",
+ array( 1 => array( $contribution['contact_id'],
'Positive' ) )
+ );
+ }
+ parent::tearDown();
+ }
+
+ protected function addContributionTracking( $ctId ) {
+ $this->ctIds[] = $ctId;
+ db_insert( 'contribution_tracking' )
+ ->fields( array( 'id' => $ctId ) )
+ ->execute();
+ }
+
+ protected function importMessage( TransactionMessage $message ) {
+ $payment_time = $message->get( 'date' );
+ exchange_rate_cache_set( 'USD', $payment_time, 1 );
+ $currency = $message->get( 'currency' );
+ if ( $currency !== 'USD' ) {
+ exchange_rate_cache_set( $currency, $payment_time, 3 );
+ }
+ $this->consumer->processMessage( $message->getBody() );
+ $contributions = wmf_civicrm_get_contributions_from_gateway_id(
+ $message->getGateway(),
+ $message->getGatewayTxnId()
+ );
+ $this->contributions[] = $contributions[0];
+ return $contributions;
+ }
public function testCreateDistinctContributions() {
civicrm_initialize();
@@ -33,32 +82,18 @@
$message = new RecurringPaymentMessage( $values );
$message2 = new RecurringPaymentMessage( $values );
- $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 );
-
$msg = $message->getBody();
- db_insert( 'contribution_tracking' )
- ->fields( array( 'id' => $msg['custom'] ) )
- ->execute();
+ $this->addContributionTracking(
$msg['contribution_tracking_id'] );
- $this->consumer->processMessage( $msg );
- $this->consumer->processMessage( $message2->getBody() );
+ $contributions = $this->importMessage( $message );
+ $contributions2 = $this->importMessage( $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'] );
@@ -77,36 +112,22 @@
$emails = $this->callAPISuccess( 'Email', 'get', array(
'contact_id' => $contributions2[0]['contact_id'] ) );
$this->assertEquals( 1, $addresses['count'] );
$this->assertEquals( '[email protected]',
$emails['values'][$emails['id']]['email'] );
-
- db_delete( 'contribution_tracking' )
- ->condition( 'id', $msg['custom'] )
- ->execute();
}
public function testNormalizedMessages() {
civicrm_initialize();
$subscr_id = mt_rand();
- $values = $this->processNormalizedRecurringSignup( $subscr_id );
+ $values = $this->processRecurringSignup( $subscr_id );
- $message = new NormalizedSubscriptionPaymentMessage( $values );
+ $message = new RecurringPaymentMessage( $values );
- $payment_time = $message->get( 'date' );
- exchange_rate_cache_set( 'USD', $payment_time, 1 );
- exchange_rate_cache_set( $message->get( 'currency' ),
$payment_time, 2 );
+ $this->addContributionTracking( $message->get(
'contribution_tracking_id' ) );
- db_insert( 'contribution_tracking' )
- ->fields( array( 'id' => $message->get(
'contribution_tracking_id' ) ) )
- ->execute();
-
- $this->consumer->processMessage( $message->getBody() );
+ $contributions = $this->importMessage( $message );
$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'] );
@@ -120,26 +141,10 @@
$emails = $this->callAPISuccess( 'Email', 'get', array(
'contact_id' => $contributions[0]['contact_id'] ) );
$this->assertEquals( 1, $addresses['count'] );
$this->assertEquals( '[email protected]',
$emails['values'][$emails['id']]['email'] );
-
- db_delete( 'contribution_tracking' )
- ->condition( 'id', $message->get(
'contribution_tracking_id' ) )
- ->execute();
- CRM_Core_DAO::executeQuery(
- "
- DELETE FROM civicrm_contribution
- WHERE id = %1",
- array( 1 => array( $contributions[0]['id'], 'Positive'
) )
- );
- CRM_Core_DAO::executeQuery(
- "
- DELETE FROM civicrm_contact
- WHERE id = %1",
- array( 1 => array( $contributions[0]['contact_id'],
'Positive' ) )
- );
}
/**
- * Test that the a blank address is not written to the DB.
+ * Test that a blank address is not written to the DB.
*/
public function testBlankEmail() {
civicrm_initialize();
@@ -147,20 +152,14 @@
$values = $this->processRecurringSignup( $subscr_id );
$message = new RecurringPaymentMessage( $values );
- $this->setExchangeRates(
- $message->get( 'payment_date' ),
- array( 'USD' => 1, $message->get( 'mc_currency' ) => 3 )
- );
$messageBody = $message->getBody();
- $addressFields = array( 'address_city', "address_country_code",
"address_country", "address_state", "address_street", "address_zip" );
+ $addressFields = array( 'city', 'country', 'state_province',
'street_address', 'postal_code' );
foreach ( $addressFields as $addressField ) {
$messageBody[$addressField] = '';
}
- db_insert( 'contribution_tracking' )
- ->fields( array( 'id' => $messageBody['custom'] ) )
- ->execute();
+ $this->addContributionTracking(
$messageBody['contribution_tracking_id'] );
$this->consumer->processMessage( $messageBody );
@@ -168,6 +167,7 @@
$message->getGateway(),
$message->getGatewayTxnId()
);
+ $this->contributions[] = $contributions[0];
$addresses = $this->callAPISuccess(
'Address',
'get',
@@ -176,9 +176,6 @@
$this->assertEquals( 1, $addresses['count'] );
// The address created by the sign up (Lockwood Rd) should not
have been overwritten by the blank.
$this->assertEquals( '5109 Lockwood Rd',
$addresses['values'][0]['street_address'] );
- db_delete( 'contribution_tracking' )
- ->condition( 'id', $messageBody['custom'] )
- ->execute();
}
/**
@@ -192,11 +189,7 @@
)
);
- $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 );
-
- $this->consumer->processMessage( $message->getBody() );
+ $this->importMessage( $message );
}
/**
@@ -210,11 +203,7 @@
)
);
- $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 );
-
- $this->consumer->processMessage( $message->getBody() );
+ $this->importMessage( $message );
}
/**
@@ -226,22 +215,6 @@
private function processRecurringSignup( $subscr_id ) {
$values = array( 'subscr_id' => $subscr_id );
$signup_message = new RecurringSignupMessage( $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 );
- $this->consumer->processMessage( $signup_message->getBody() );
- return $values;
- }
-
- /**
- * Process the original recurring sign up message.
- *
- * @param string $subscr_id
- * @return array
- */
- private function processNormalizedRecurringSignup( $subscr_id ) {
- $values = array( 'subscr_id' => $subscr_id );
- $signup_message = new NormalizedRecurringSignupMessage( $values
);
$subscr_time = $signup_message->get( 'date' );
exchange_rate_cache_set( 'USD', $subscr_time, 1 );
exchange_rate_cache_set( $signup_message->get( 'currency' ),
$subscr_time, 2 );
--
To view, visit https://gerrit.wikimedia.org/r/349253
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I311643d40cb3503f95abb18291fbd871091c333e
Gerrit-PatchSet: 4
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits