Eileen has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/363290 )
Change subject: Merge branch 'master' of https://gerrit.wikimedia.org/r/wikimedia/fundraising/crm into deployment ...................................................................... Merge branch 'master' of https://gerrit.wikimedia.org/r/wikimedia/fundraising/crm into deployment 263222b3ff300711cb3fb2eb164529a5b46bff0c Test tidy ups, ensure data from failed run doesn not break test c8eaf54055cf16983b1ac55e26b25a096eed6d8d Remove further instance of class_api in favour of civicrm_api3 ec413e77b1420c6894642c15d316aca33cc72625 Stop calling deprecated function. c3eecf3aed0b672b4a429af5b3338975545c2d3d Remove deprecated function call from unit test. 44894d6cc4e6d875abc92cfa07c437cfcf84d88e Enable CiviCampaign. 3676cf5ddfedeb17c06fdb86219d0514758cbeb9 Specify output directory for make-exchange-refs 48baba94e0b087eb32a61247440b4afb9d455d0d $correlationId -> $logId 02955c188a62ff110cd09e9ea62662e62b32425c CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontribute permission for contribution recur.cancel 5781882 CiviCRM composer update. c4adb98c4309063a5e1d3ad4945ff4f2056983c8 Add index to civicrm_campaign.name Change-Id: I0026fbe243c33b8ceb6c96c845d0ef93b082991d --- D sites/all/modules/large_donation/tests/LargeDonationTest.php D sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php D sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php D sites/all/modules/queue2civicrm/tests/data/payments-antifraud.json D sites/all/modules/queue2civicrm/tests/includes/Message.php D sites/all/modules/wmf_civicrm/tests/phpunit/PhoneImportTest.php D sites/all/modules/wmf_communication/tests/phpunit/CiviMailBulkTest.php 7 files changed, 0 insertions(+), 574 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/90/363290/1 diff --git a/sites/all/modules/large_donation/tests/LargeDonationTest.php b/sites/all/modules/large_donation/tests/LargeDonationTest.php deleted file mode 100644 index 72f4b15..0000000 --- a/sites/all/modules/large_donation/tests/LargeDonationTest.php +++ /dev/null @@ -1,75 +0,0 @@ -<<<<<<< HEAD (e53d62 CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontrib) -======= -<?php - -use wmf_communication\TestMailer; - -/** - * @group LargeDonation - */ -class LargeDonationTest extends BaseWmfDrupalPhpUnitTestCase { - function setUp() { - parent::setUp(); - civicrm_initialize(); - - TestMailer::setup(); - - $this->threshold = 100; - - db_delete( 'large_donation_notification' ) - ->execute(); - - db_insert( 'large_donation_notification' ) - ->fields( array( - 'addressee' => '[email protected]', - 'threshold' => $this->threshold, - ) ) - ->execute(); - - $result = $this->callAPISuccess('Contact', 'create', array( - 'contact_type' => 'Individual', - 'first_name' => 'Testes', - )); - $this->contact_id = $result['id']; - } - - function tearDown() { - db_delete( 'large_donation_notification' ) - ->execute(); - - parent::tearDown(); - } - - function testUnderThreshold() { - $result = civicrm_api3( 'Contribution', 'create', array( - 'contact_id' => $this->contact_id, - 'contribution_type' => 'Cash', - 'currency' => 'USD', - 'payment_instrument' => 'Credit Card', - 'total_amount' => $this->threshold - 0.01, - 'trxn_id' => 'TEST_GATEWAY ' . mt_rand(), - ) ); - - $this->assertEquals( 0, TestMailer::countMailings() ); - } - - function testAboveThreshold() { - $amount = $this->threshold + 0.01; - $this->callAPISuccess('Contribution', 'create', array( - 'contact_id' => $this->contact_id, - 'contribution_type' => 'Cash', - 'currency' => 'USD', - 'payment_instrument' => 'Credit Card', - 'total_amount' => $amount, - 'trxn_id' => 'TEST_GATEWAY ' . mt_rand(), - 'source' => 'EUR 2020', - ) ); - - $this->assertEquals( 1, TestMailer::countMailings() ); - - $mailing = TestMailer::getMailing( 0 ); - $this->assertEquals( 1, preg_match( "/{$amount}/", $mailing['html'] ), - 'Found amount in the notification email body.' ); - } -} ->>>>>>> BRANCH (c4adb9 Add index to civicrm_campaign.name) diff --git a/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php deleted file mode 100644 index f8ca11c..0000000 --- a/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php +++ /dev/null @@ -1,84 +0,0 @@ -<<<<<<< HEAD (e53d62 CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontrib) -======= -<?php - -require_once __DIR__ . "/includes/BaseChecksFileTest.php"; - -/** - * @group Import - * @group Offline2Civicrm - */ -class ForeignChecksFileTest extends BaseChecksFileTest { - function setUp() { - parent::setUp(); - civicrm_initialize(); - $this->epochtime = wmf_common_date_parse_string('2017-02-28'); - $this->setExchangeRates($this->epochtime, array('USD' => 1, 'GBP' => 2)); - - require_once __DIR__ . "/includes/ForeignChecksFileProbe.php"; - } - - function testParseRow() { - $data = array( - 'Batch Number' => '1234', - 'Original Amount' => '50.00', - 'Original Currency' => 'GBP', - 'Received Date' => '4/1/14', - 'Payment Instrument' => 'Check', - 'Check Number' => '2020', - 'First Name' => 'Gen', - 'Last Name' => 'Russ', - 'Street Address' => '1000 Markdown Markov', - 'Additional Address' => '', - 'City' => 'Chocolate City', - 'State' => 'ND', - 'Postal Code' => '13131', - 'Country' => 'Nonexistent Rock Candy Country', - 'Email' => '', - 'Phone' => '', - 'Thank You Letter Date' => '', - 'No Thank You' => '', - 'Direct Mail Appeal' => '', - 'AC Flag' => '', - 'Restrictions' => '', - 'Gift Source' => '', - 'Notes' => '', - ); - $expected_normal = array( - 'check_number' => '2020', - 'city' => 'Chocolate City', - 'country' => 'Nonexistent Rock Candy Country', - 'first_name' => 'Gen', - 'last_name' => 'Russ', - 'gateway' => 'check', - 'gross' => '50.00', - 'currency' => 'GBP', - 'payment_method' => 'Check', - 'postal_code' => '13131', - 'date' => 1396310400, - 'state_province' => 'ND', - 'street_address' => '1000 Markdown Markov', - 'contact_source' => 'check', - 'contact_type' => 'Individual', - 'gateway_txn_id' => '3333f8fd5703c6a319c4a9d2b5a2d8c6', - ); - - $importer = new ForeignChecksFileProbe( "null URI" ); - $output = $importer->_parseRow( $data ); - - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } - - /** - * Test that all imports fail if the organization does not pre-exist. - */ - function testImportForeignCheckes() { - $importer = new ForeignChecksFile( __DIR__ . "/data/foreign_checks_trilogy.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - } - -} ->>>>>>> BRANCH (c4adb9 Add index to civicrm_campaign.name) diff --git a/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php deleted file mode 100644 index 7682651..0000000 --- a/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php +++ /dev/null @@ -1,73 +0,0 @@ -<<<<<<< HEAD (e53d62 CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontrib) -======= -<?php - -class BaseChecksFileTest extends BaseWmfDrupalPhpUnitTestCase { - /** - * Gateway. - * - * eg. jpmorgan, paypal etc. - * - * @var string - */ - protected $gateway; - - /** - * Transaction id being worked with. This is combined with the gateway for the civi trxn_id. - * - * @var string - */ - protected $trxn_id; - /** - * Test and remove some dynamic fields, to simplify test fixtures. - */ - function stripSourceData( &$msg ) { - $this->assertEquals( 'direct', $msg['source_type'] ); - $importerClass = str_replace( 'Test', 'Probe', get_class( $this ) ); - $this->assertEquals( "Offline importer: {$importerClass}", $msg['source_name'] ); - $this->assertNotNull( $msg['source_host'] ); - $this->assertGreaterThan( 0, $msg['source_run_id'] ); - $this->assertNotNull( $msg['source_version'] ); - $this->assertGreaterThan( 0, $msg['source_enqueued_time'] ); - - unset( $msg['source_type'] ); - unset( $msg['source_name'] ); - unset( $msg['source_host'] ); - unset( $msg['source_run_id'] ); - unset( $msg['source_version'] ); - unset( $msg['source_enqueued_time'] ); - } - - /** - * Clean up after test runs. - */ - public function tearDown() { - $this->doCleanUp(); - } - - /** - * Clean up transactions from previous test runs. - */ - function doCleanUp() { - if ($this->trxn_id) { - $contributions = wmf_civicrm_get_contributions_from_gateway_id($this->gateway, $this->trxn_id); - if ($contributions) { - foreach ($contributions as $contribution) { - $this->callAPISuccess('Contribution', 'delete', array('id' => $contribution['id'])); - } - } - } - $this->doMouseHunt(); - } - - /** - * Clean up previous runs. - * - * Also get rid of the nest. - */ - protected function doMouseHunt() { - CRM_Core_DAO::executeQuery('DELETE FROM civicrm_contact WHERE display_name = "Mickey Mouse"'); - CRM_Core_DAO::executeQuery('DELETE FROM civicrm_prevnext_cache'); - } -} ->>>>>>> BRANCH (c4adb9 Add index to civicrm_campaign.name) diff --git a/sites/all/modules/queue2civicrm/tests/data/payments-antifraud.json b/sites/all/modules/queue2civicrm/tests/data/payments-antifraud.json deleted file mode 100644 index ef88ce0..0000000 --- a/sites/all/modules/queue2civicrm/tests/data/payments-antifraud.json +++ /dev/null @@ -1,27 +0,0 @@ -<<<<<<< HEAD (e53d62 CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontrib) -======= -{ - "validation_action": "process", - "risk_score": "0.3", - "score_breakdown": { - "initial": "0", - "getCVVResult": "0.2", - "getAVSResult": "0", - "getScoreCountryMap": "0", - "getScoreUtmCampaignMap": "0", - "getScoreEmailDomainMap": "0", - "minfraud_filter": "0.10", - "IPVelocityFilter": "0" - }, - "php-message-class": "SmashPig\\CrmLink\\Messages\\DonationInterfaceAntifraud", - "user_ip": "1.2.3.4", - "freeform": "1", - "gateway_txn_id": "", - "date": "1445990975", - "server": "testpayments1001", - "gateway": "testgateway", - "contribution_tracking_id": "28713751", - "order_id": "28713751.0", - "payment_method": "cc" -} ->>>>>>> BRANCH (c4adb9 Add index to civicrm_campaign.name) diff --git a/sites/all/modules/queue2civicrm/tests/includes/Message.php b/sites/all/modules/queue2civicrm/tests/includes/Message.php deleted file mode 100644 index 12f314d..0000000 --- a/sites/all/modules/queue2civicrm/tests/includes/Message.php +++ /dev/null @@ -1,162 +0,0 @@ -<<<<<<< HEAD (e53d62 CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontrib) -======= -<?php - -class Message { - protected $defaults = array(); - - public $body; - - protected $data; - - function __construct( $values = array() ) { - $this->data = $this->defaults; - $this->set( $values ); - } - - function set( $values ) { - if ( is_array( $values ) ) { - $this->data = $values + $this->data; - } - - $this->body = json_encode( $this->data ); - } - - function getBody() { - return $this->data; - } - - function loadDefaults( $name ) { - if ( !$this->defaults ) { - $path = __DIR__ . "/../data/{$name}.json"; - $this->defaults = json_decode( file_get_contents( $path ), true ); - } - } - - /** - * Generates random data for queue and donation insertion testing - */ - public static function generateRandom() { - //language codes - $lang = array( 'en', 'de', 'fr' ); - - $currency_codes = array( 'USD', 'GBP', 'EUR', 'ILS' ); - shuffle( $currency_codes ); - $currency = ( mt_rand( 0, 1 ) ) ? 'USD' : $currency_codes[0]; - - $message = array( - 'contribution_tracking_id' => '', - 'optout' => mt_rand( 0, 1 ), - 'anonymous' => mt_rand( 0, 1 ), - 'comment' => mt_rand(), - 'utm_source' => mt_rand(), - 'utm_medium' => mt_rand(), - 'utm_campaign' => mt_rand(), - 'language' => $lang[array_rand( $lang )], - 'email' => mt_rand() . '@example.com', - 'first_name' => mt_rand(), - 'middle_name' => mt_rand(), - 'last_name' => mt_rand(), - 'street_address' => mt_rand(), - 'supplemental_address_1' => '', - 'city' => 'San Francisco', - 'state_province' => 'CA', - 'country' => 'USA', - 'countryID' => 'US', - 'postal_code' => mt_rand( 2801, 99999 ), - 'gateway' => 'insert_test', - 'gateway_txn_id' => mt_rand(), - 'response' => mt_rand(), - 'currency' => $currency, - 'original_currency' => $currency_codes[0], - 'original_gross' => mt_rand( 0, 10000 ) / 100, - 'fee' => '0', - 'gross' => mt_rand( 0, 10000 ) / 100, - 'net' => mt_rand( 0, 10000 ) / 100, - 'date' => date( 'r' ), //time(), - ); - return $message; - } -} - -class TransactionMessage extends Message { - protected $txn_id_key = 'gateway_txn_id'; - - function __construct( $values = array() ) { - $this->loadDefaults( "donation" ); - - parent::__construct( array( - $this->txn_id_key => mt_rand(), - 'order_id' => mt_rand(), - ) + $values ); - } - - function getGateway() { - return $this->data['gateway']; - } - - function getGatewayTxnId() { - return $this->data[$this->txn_id_key]; - } - - function get( $key ) { - return $this->data[$key]; - } -} - -class RefundMessage extends TransactionMessage { - function __construct( $values = array() ) { - $this->loadDefaults( "refund" ); - - $this->txn_id_key = 'gateway_refund_id'; - - parent::__construct( $values ); - } -} - -class RecurringPaymentMessage extends TransactionMessage { - function __construct( $values = array() ) { - $this->loadDefaults( "recurring_payment" ); - - $this->txn_id_key = 'gateway_txn_id'; - - parent::__construct( $values ); - } -} - -class RecurringSignupMessage extends TransactionMessage { - function __construct( $values = array() ) { - $this->loadDefaults( "recurring_signup" ); - - parent::__construct( $values ); - } -} - -/** - * Class AmazonDonationMessage Sparse message format pointing to donor - * details in the pending database - */ -class AmazonDonationMessage extends TransactionMessage { - function __construct( $values = array() ) { - $this->loadDefaults( "sparse_donation_amazon" ); - - parent::__construct( $values ); - $this->data['completion_message_id'] = - 'amazon-' . $this->get( 'order_id' ); - } -} - -/** - * Class AstroPayDonationMessage Sparse message format pointing to donor - * details in the pending database - */ -class AstroPayDonationMessage extends TransactionMessage { - function __construct( $values = array() ) { - $this->loadDefaults( "sparse_donation_astropay" ); - - parent::__construct( $values ); - $this->data['completion_message_id'] = - 'astropay-' . $this->get( 'order_id' ); - } -} ->>>>>>> BRANCH (c4adb9 Add index to civicrm_campaign.name) diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/PhoneImportTest.php b/sites/all/modules/wmf_civicrm/tests/phpunit/PhoneImportTest.php deleted file mode 100644 index 006a81a..0000000 --- a/sites/all/modules/wmf_civicrm/tests/phpunit/PhoneImportTest.php +++ /dev/null @@ -1,50 +0,0 @@ -<<<<<<< HEAD (e53d62 CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontrib) -======= -<?php - -/** - * @group Pipeline - * @group WmfCivicrm - */ -class PhoneImportTest extends BaseWmfDrupalPhpUnitTestCase { - - public function testPhoneImport() { - $this->refreshStripFunction(); - - $phoneNumber = '555-555-5555'; - - $msg = array( - 'currency' => 'USD', - 'date' => time(), - 'email' => '[email protected]', - 'gateway' => 'test_gateway', - 'gateway_txn_id' => mt_rand(), - 'gross' => '1.23', - 'payment_method' => 'cc', - 'phone' => $phoneNumber, - ); - - $contribution = wmf_civicrm_contribution_message_import( $msg ); - - $phones = $this->callAPISuccess('Phone', 'get', array('contact_id' => $contribution['contact_id'], 'sequential' => 1)); - $phone = $phones['values'][0]; - - $this->assertEquals($phoneNumber, $phone['phone']); - $this->assertEquals(1, $phone['is_primary']); - $this->assertEquals(wmf_civicrm_get_default_location_type_id(), $phone['location_type_id']); - $this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Phone'), $phone['phone_type_id']); - } - - /** - * This SQL function is not created during the test at the right time & it seems the triggers ARE - * created despite it not being present. This is not an issue on live (where the function seems to already exist). - */ - public function refreshStripFunction() { - civicrm_initialize(); - CRM_Core_DAO::executeQuery(CRM_Contact_BAO_Contact::DROP_STRIP_FUNCTION_43); - CRM_Core_DAO::executeQuery(CRM_Contact_BAO_Contact::CREATE_STRIP_FUNCTION_43); - CRM_Core_DAO::executeQuery("UPDATE civicrm_phone SET phone_numeric = civicrm_strip_non_numeric(phone)"); - } - -} ->>>>>>> BRANCH (c4adb9 Add index to civicrm_campaign.name) diff --git a/sites/all/modules/wmf_communication/tests/phpunit/CiviMailBulkTest.php b/sites/all/modules/wmf_communication/tests/phpunit/CiviMailBulkTest.php deleted file mode 100644 index 70dba32..0000000 --- a/sites/all/modules/wmf_communication/tests/phpunit/CiviMailBulkTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<<<<<<< HEAD (e53d62 CiviCRM Submodule update 9e4899f CRM-20778 - Use civicontrib) -======= -<?php -namespace wmf_communication; - -use \CRM_Activity_BAO_Activity; -use \CRM_Activity_BAO_ActivityTarget; -use \CRM_Core_OptionGroup; -use \CRM_Mailing_BAO_Recipients; -use \CRM_Mailing_Event_BAO_Queue; -use \CRM_Mailing_Event_BAO_Delivered; -/** - * Tests for CiviMail helper classes - * @group CiviMail - * @group WmfCommunication - */ -class CiviMailBulkTest extends CiviMailTestBase { - - protected $contacts = array(); - protected $emails = array(); - /** - * @var ICiviMailBulkStore - */ - protected $bulkMailStore; - - public function setUp() { - parent::setUp(); - - $this->bulkMailStore = new CiviMailBulkStore(); - - for ( $i = 1; $i <= 10; $i++ ) { - $emailAddress = "[email protected]"; - $firstName = "Kevin$i"; - $lastName = 'Hondo'; - - $contact = $this->getContact( $emailAddress, $firstName, $lastName ); - - $this->contacts[] = $contact + array( 'emailAddress' => $emailAddress ); - $this->emails[] = $emailAddress; - } - } - - public function tearDown() { - parent::tearDown(); - foreach ( $this->contacts as $contact ) { - civicrm_api3( 'Email', 'delete', array( 'id' => $contact['emailID'] ) ); - civicrm_api3( 'Contact', 'delete', array( 'id' => $contact['contactID'] ) ); - } - } - - public function testAddSentBulk() { - $name = 'test_mailing'; - $revision = mt_rand(); - $storedMailing = $this->mailStore->addMailing( - $this->source, - $name, - $this->body, - $this->subject, - $revision - ); - - $this->bulkMailStore->addSentBulk( $storedMailing, $this->emails ); - - $mailingID = $storedMailing->getMailingID(); - // Should have a single bulk mailing activity created - $activities = $this->callAPISuccess('Activity', 'get', array( - 'source_record_id' => $mailingID, - 'activity_type_id' => 'Bulk Email', - )); - $this->assertTrue($activities['count'] === 1); - - foreach ( $this->contacts as $contact ) { - //recipients table - $recipients = new CRM_Mailing_BAO_Recipients(); - $recipients->mailing_id = $mailingID; - $recipients->contact_id = $contact['contactID']; - $recipients->email_id = $contact['emailID']; - $this->assertTrue( $recipients->find() && $recipients->fetch() ); - - //queue entry - $queueQuery = "SELECT q.id, q.contact_id -FROM civicrm_mailing_event_queue q -INNER JOIN civicrm_mailing_job j ON q.job_id = j.id -WHERE j.mailing_id = $mailingID"; - - $queue = new CRM_Mailing_Event_BAO_Queue(); - $queue->query( $queueQuery ); - $this->assertTrue( $queue->fetch() ); - - //delivery event - $delivered = new CRM_Mailing_Event_BAO_Delivered(); - $delivered->event_queue_id = $queue->id; - $this->assertTrue( $delivered->find() && $delivered->fetch() ); - - //activity target - $activityTarget = new CRM_Activity_BAO_ActivityTarget(); - $activityTarget->activity_id = $activities['id']; - $activityTarget->target_contact_id = $contact['contactID']; - $this->assertTrue( $activityTarget->find() && $activityTarget->fetch() ); - } - } -} ->>>>>>> BRANCH (c4adb9 Add index to civicrm_campaign.name) -- To view, visit https://gerrit.wikimedia.org/r/363290 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0026fbe243c33b8ceb6c96c845d0ef93b082991d Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: deployment Gerrit-Owner: Eileen <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
