jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/342155 )
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 + 3b4798099b65e239b2a56379f54e0d90f30f0924 Normalized subscr_ messages for tests + 41826252f5c2fb75c69c1c69eb0a791015d7b79f Remove unchanged insertions of blank addresses. + aec23907e99cfb4228b6e0333f712a2c54e596e6 Remove obsolete blank address from tracking table. + 54439c652fe886d53981824bc9bc3d4116300911 Remove bulk update blank addresses from being treated as 'updates'. + da48b2a9f00c3066159d7c59ecc7d7a4a1c9c057 Add trilogy payment_method to foreign checks import + a5043f6da76330677d9152b7c39fe8f5986cc727 Add & use Benevity financial type. + 2b6b8b851fcfa377849b873821a9444987b852bc Submodule update for CiviCRM 91d02f7 CRM-20061 Add tables as a parameter on the revert api + 86111d242bc9623b793b617323284f6aae652164 Benevity import, still create relationship when no individual gift + 0b8ab4e43a73b989be6608ad39061015c1da6331 Loosen Benevity matching logic for individuals. + ea0b2b5c0891e5257c71f012e314405f0ffe5c74 More loosening of benevity matching logic. + 9d14b17cc3c167522b5e9681213cd8cc6b01d922 Even more loosening of benevity matching logic. Change-Id: Icfd0abbd599115efdefe96ab2fa01f23858d3765 --- D sites/all/modules/offline2civicrm/tests/BenevityTest.php D sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php D sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv D sites/all/modules/offline2civicrm/tests/data/foreign_checks_trilogy.csv D sites/all/modules/queue2civicrm/tests/data/subscr_payment_normalized.json D sites/all/modules/queue2civicrm/tests/data/subscr_signup_normalized.json 6 files changed, 0 insertions(+), 683 deletions(-) Approvals: jenkins-bot: Verified Eileen: Looks good to me, approved diff --git a/sites/all/modules/offline2civicrm/tests/BenevityTest.php b/sites/all/modules/offline2civicrm/tests/BenevityTest.php deleted file mode 100644 index f3a138e..0000000 --- a/sites/all/modules/offline2civicrm/tests/BenevityTest.php +++ /dev/null @@ -1,548 +0,0 @@ -<<<<<<< HEAD (d20ed4 Merge master into deployment) -======= -<?php - -/** - * @group Import - * @group Offline2Civicrm - * - * Refer to this comment in Phab for rules about when contacts are created. These are - * the rules the tests are working to (and both should be updated to reflect rule changes). - * https://phabricator.wikimedia.org/T115044#3012232 - */ -class BenevityTest extends BaseChecksFileTest { - protected $epochtime; - - function setUp() { - parent::setUp(); - - $this->epochtime = wmf_common_date_parse_string('2016-09-15'); - $this->setExchangeRates($this->epochtime, array('USD' => 1, 'BTC' => 3)); - $this->gateway = 'benevity'; - civicrm_initialize(); - CRM_Core_DAO::executeQuery(" - DELETE FROM civicrm_contribution - WHERE trxn_id LIKE 'BENEVITY%' - "); - CRM_Core_DAO::executeQuery(" - DELETE FROM civicrm_contact - WHERE organization_name IN('Donald Duck Inc', 'Mickey Mouse Inc', 'Goofy Inc', 'Uncle Scrooge Inc') - OR nick_name IN('Donald Duck Inc', 'Mickey Mouse Inc', 'Goofy Inc', 'Uncle Scrooge Inc') - OR first_name = 'Minnie' AND last_name = 'Mouse' - OR first_name = 'Pluto' - "); - $this->ensureAnonymousContactExists(); - \Civi::$statics = array(); - $countries = $this->callAPISuccess('Country', 'get', array()); - $this->callAPISuccess('Setting', 'create', array('countryLimit' => array_keys($countries['values']))); - - } - - /** - * Make sure we have the anonymous contact - like the live DB. - */ - protected function ensureAnonymousContactExists() { - $anonymousParams = array( - 'first_name' => 'Anonymous', - 'last_name' => 'Anonymous', - 'email' => 'fakeem...@wikimedia.org', - 'contact_type' => 'Individual', - ); - $contacts = $this->callAPISuccess('Contact', 'get', $anonymousParams); - if ($contacts['count'] == 0) { - $this->callAPISuccess('Contact', 'create', $anonymousParams); - } - $contacts = $this->callAPISuccess('Contact', 'get', $anonymousParams); - $this->assertEquals(1, $contacts['count']); - } - - /** - * Test that all imports fail if the organization has multiple matches. - */ - function testImportFailOrganizationContactAmbiguous() { - $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Donald Duck Inc', 'contact_type' => 'Organization')); - $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Donald Duck Inc', 'contact_type' => 'Organization')); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('0 out of 4 rows were imported.', $messages['Result']); - } - - /** - * Test that all imports fail if the organization does not pre-exist. - */ - function testImportFailNoOrganizationContactExists() { - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('0 out of 4 rows were imported.', $messages['Result']); - } - - /** - * Test that import passes for the contact if a single match is found. - */ - function testImportSucceedOrganizationSingleContactExists() { - $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Donald Duck Inc', 'contact_type' => 'Organization')); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - } - - /** - * Test that import passes for the Individual contact if a single match is found. - */ - function testImportSucceedIndividualSingleContactExists() { - $thaMouseMeister = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $minnie['id'])); - $this->assertEquals(1, $contributions['count']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $minnie['id'], 'contact_id_b' => $thaMouseMeister['id'])); - $this->assertEquals(1, $relationships['count']); - } - - /** - * Test that import passes for the Individual contact when no single match is found. - * - * In this scenario an email exists so a contact is created. The origanization exists and can be - * matched, however the individual does not exist & should be created. - */ - function testImportSucceedIndividualNoExistingMatch() { - $thaMouseMeister = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - $contribution = $this->callAPISuccessGetSingle('Contribution', array('trxn_id' => 'BENEVITY TRXN-SQUEAK')); - $this->assertEquals('Benevity', $contribution['financial_type']); - $relationships = $this->callAPISuccess('Relationship', 'get', array( - 'contact_id_a' => $contribution['contact_id'], - 'contact_id_b' => $thaMouseMeister['id']) - ); - $this->assertEquals(1, $relationships['count']); - } - - /** - * Test that import works when creating a contact just for the matching gift. - * - * In this scenario an email exists so a contact is created. The contact does - * not make a donation but is soft credited the organisation's donation. - */ - function testImportSucceedIndividualNoExistingMatchOnlyMatchingGift() { - $thaMouseMeister = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $relationships = $this->callAPISuccess('Relationship', 'get', array( - 'contact_id_b' => $thaMouseMeister['id']) - ); - $this->assertEquals(0, $relationships['count']); - - $importer = new BenevityFile( __DIR__ . "/data/benevity_only_match.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - $contribution = $this->callAPISuccessGetSingle('Contribution', array('trxn_id' => 'BENEVITY TRXN-SQUEAK_MATCHED')); - $relationship = $this->callAPISuccessGetSingle('Relationship', array( - 'contact_id_b' => $thaMouseMeister['id']) - ); - $this->assertEquals( $relationship['contact_id_a'], $contribution['soft_credit_to']); - } - - /** - * Test when creating a contact just for the matching gift on a soft credit match. - * - * In this scenario the contact is matched based on a prior soft credit. Their - * email is ignored to make this match. - * - * The contact does not make a donation but is soft credited the organisation's donation. - * - * We are checking the relationship is created. - */ - function testImportSucceedIndividualSofCreditMatchMatchingGiftNoDonorGift() { - $thaMouseMeister = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'minnie@mouse_home.org' - )); - // Create a contribution on the organisation, soft credited to Better Minnie. - $this->callAPISuccess('Contribution', 'create', array( - 'total_amount' => 4, - 'financial_type_id' => 'Donation', - 'soft_credit_to' => $minnie['id'], - 'contact_id' => $thaMouseMeister['id'], - )); - - $importer = new BenevityFile( __DIR__ . "/data/benevity_only_match.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - $contribution = $this->callAPISuccessGetSingle('Contribution', array('trxn_id' => 'BENEVITY TRXN-SQUEAK_MATCHED')); - $relationship = $this->callAPISuccessGetSingle('Relationship', array( - 'contact_id_b' => $thaMouseMeister['id']) - ); - $this->assertEquals( $relationship['contact_id_a'], $contribution['soft_credit_to']); - } - - /** - * Test that import resolves ambiguous individuals by choosing based on the employer. - */ - function testImportSucceedIndividualDismabiguateByEmployer() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - $betterMinnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', 'employer_id' => $organization['id'], - )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $minnie['id'])); - $this->assertEquals(0, $contributions['count']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $betterMinnie['id'])); - $this->assertEquals(1, $contributions['count']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $betterMinnie['id'], 'contact_id_b' => $organization['id'])); - $this->assertEquals(1, $relationships['count']); - } - - /** - * Test that import creates new contacts when it can't resolve to a single contact. - */ - function testImportSucceedIndividualTooManyChoicesCantDecideSpamTheDB() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - $doppelgangerMinnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - $importer = new BenevityFile( __DIR__ . "/data/benevity_mice_no_email.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - - // All you Minnie's are not the real Minnie - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $minnie['id'])); - $this->assertEquals(0, $contributions['count']); - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $doppelgangerMinnie['id'])); - $this->assertEquals(0, $contributions['count']); - - // Will the Real Minnie Mouse Please stand up. - $relationship = $this->callAPISuccessGetSingle('Relationship', array('contact_id_b' => $organization['id'])); - $this->assertNotEquals($minnie['id'], $relationship['contact_id_a']); - $this->assertNotEquals($doppelgangerMinnie['id'], $relationship['contact_id_a']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $relationship['contact_id_a'])); - $this->assertEquals(2, $contributions['count']); - } - - /** - * Test that import resolves ambiguous individuals by choosing based on the employer where nick_name match in play. - */ - function testImportSucceedIndividualDismabiguateByEmployerNickName() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Micey', 'nick_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - $betterMinnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', 'employer_id' => $organization['id'], - )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $minnie['id'])); - $this->assertEquals(0, $contributions['count']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $betterMinnie['id'])); - $this->assertEquals(1, $contributions['count']); - } - - /** - * Test that import resolves ambiguous individuals based on previous soft credit history. - * - * If an organisation has previously soft credited an individual we consider that - * to be equivalent to an employer relationship having been formed. - * - * Probably longer term the employment relationships will exist and this will be redundant. - */ - function testImportSucceedIndividualDismabiguateByPreviousSoftCredit() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - $betterMinnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - // Create a contribution on the organisation, soft credited to Better Minnie. - $this->callAPISuccess('Contribution', 'create', array( - 'total_amount' => 4, - 'financial_type_id' => 'Donation', - 'soft_credit_to' => $betterMinnie['id'], - 'contact_id' => $organization['id'], - )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $minnie['id'])); - $this->assertEquals(0, $contributions['count']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $betterMinnie['id'])); - $this->assertEquals(1, $contributions['count']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $betterMinnie['id'], 'contact_id_b' => $organization['id'])); - $this->assertEquals(1, $relationships['count']); - } - - /** - * Test that we will accept a name match for employees, even when there is an email mis-match. - * - * We have a situation where employees are often in the database with a different email than in - * the Benevity import (e.g a personal email). If there is already a contact with the same first and - * last name and they have been related to the organization (by an employer relationship or a previous - * soft credit) we should accept them. - */ - function testImportSucceedIndividualMatchToEmployerDisregardingEmail() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $betterMinnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'minnie@mouse_home.org', 'employer_id' => $organization['id'], - )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $betterMinnie['id'])); - $this->assertEquals(1, $contributions['count']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $betterMinnie['id'], 'contact_id_b' => $organization['id'])); - $this->assertEquals(1, $relationships['count']); - $emails = $this->callAPISuccess('Email', 'get', array('contact_id' => $betterMinnie['id'], 'sequential' => 1)); - $this->assertEquals(2, $emails['count']); - $this->assertEquals(1, $emails['values'][0]['is_primary']); - $this->assertEquals('minnie@mouse_home.org', $emails['values'][0]['email']); - $this->assertEquals(0, $emails['values'][1]['is_primary']); - $this->assertEquals('min...@mouse.org', $emails['values'][1]['email']); - } - - /** - * Check that without an email the match is accepted with an employer connection. - * - */ - function testImportSucceedIndividualOneMatchNoEmailEmployerMatch() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - - $betterMinnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', - 'email' => 'min...@mouse.org', 'employer_id' => $organization['id'], - )); - - $importer = new BenevityFile( __DIR__ . "/data/benevity_mice_no_email.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $minnie['id'])); - $this->assertEquals(0, $contributions['count']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array( - 'contact_id' => $betterMinnie['id'], - 'sequential' => 1, - 'return' => array( - wmf_civicrm_get_custom_field_name('no_thank_you'), - wmf_civicrm_get_custom_field_name('Fund'), - wmf_civicrm_get_custom_field_name('Campaign') - ), - )); - $this->assertEquals(2, $contributions['count']); - $contribution1 = $contributions['values'][0]; - $this->assertEquals(1, $contribution1[wmf_civicrm_get_custom_field_name('no_thank_you')], 'No thank you should be set'); - $this->assertEquals('Community Gift', $contribution1[wmf_civicrm_get_custom_field_name('Campaign')]); - $this->assertEquals('Unrestricted - General', $contribution1[wmf_civicrm_get_custom_field_name('Fund')]); - - $contribution2 = $contributions['values'][1]; - $this->assertEquals(1, $contribution2[wmf_civicrm_get_custom_field_name('no_thank_you')]); - // This contribution was over $1000 & hence is a benefactor gift. - $this->assertEquals('Benefactor Gift', $contribution2[wmf_civicrm_get_custom_field_name('Campaign')]); - $this->assertEquals('Unrestricted - General', $contribution2[wmf_civicrm_get_custom_field_name('Fund')]); - - $organizationContributions = $this->callAPISuccess('Contribution', 'get', array( - 'contact_id' => $organization['id'], - 'sequential' => 1, - 'return' => array( - wmf_civicrm_get_custom_field_name('no_thank_you'), - wmf_civicrm_get_custom_field_name('Fund'), - wmf_civicrm_get_custom_field_name('Campaign') - ), - )); - foreach ($organizationContributions['values'] as $contribution) { - $this->assertEquals(1, $contribution[wmf_civicrm_get_custom_field_name('no_thank_you')]); - $this->assertEquals('Restricted - Foundation', $contribution[wmf_civicrm_get_custom_field_name('Fund')]); - $this->assertEquals('Matching Gift', $contribution[wmf_civicrm_get_custom_field_name('Campaign')]); - } - } - - /** - * Check that without an email & no employer connection a match is not made. - * - * If there is no employer connection a new contact should be created. - */ - function testImportSucceedIndividualOneMatchNoEmailNoEmployerMatch() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $minnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', - )); - - $importer = new BenevityFile( __DIR__ . "/data/benevity_mice_no_email.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $minnie['id'])); - $this->assertEquals(0, $contributions['count']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_b' => $organization['id'])); - $this->assertEquals(1, $relationships['count']); - $individualID = $relationships['values'][$relationships['id']]['contact_id_a']; - $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $individualID)); - // Note that both importees have been matched up. They are both legit matches based on our rules. - // It feels weird because one has less data than the other. But single name contacts should be - // very rare & single name contacts that match a different double-name contact in the same - // org seems 'beyond-edge' - $this->assertEquals(2, $contributions['count']); - } - - /** - * Test that rollback works. - * - * If part of the transaction fails it should be fully rolled back. Here we - * ensure the second transaction fails and the created individual and created - * contribution have also been rolled back. - */ - function testImportDuplicateFullRollback() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - // This will clash with the second transaction causing it to fail. - - $this->callAPISuccess('Contribution', 'create', array( - 'trxn_id' => 'BENEVITY TRXN-SQUEAK_MATCHED', - 'financial_type_id' => 'Engage', - 'total_amount' => 5, - 'contact_id' => $organization['id'], - )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('0 out of 4 rows were imported.', $messages['Result']); - $contribution = $this->callAPISuccess('Contribution', 'get', array('trxn_id' => 'BENEVITY TRXN-SQUEAK')); - $this->assertEquals(0, $contribution['count'], 'This contribution should have been rolled back'); - $minnie = $this->callAPISuccess('Contact', 'get', array('first_name' => 'Minnie', 'last_name' => 'Mouse')); - $this->assertEquals(0, $minnie['count'], 'This contact should have been rolled back'); - } - - /** - * Test import succeeds if there is exactly one organization with the name as a nick name. - * - * If this is the case then the presence of other organizations with that name as a name - * should not be a problem. - */ - function testImportSucceedOrganizationDisambiguatedBySingleNickName() { - $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Donald Duck Inc', 'contact_type' => 'Organization')); - $theRealDuck = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Donald Duck', 'nick_name' => 'Donald Duck Inc', 'contact_type' => 'Organization')); - $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Donald Duck Inc', 'contact_type' => 'Organization')); - - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); - $contribution = $this->callAPISuccessGetSingle('Contribution', array('trxn_id' => 'BENEVITY TRXN-QUACK')); - $this->assertEquals(200, $contribution['total_amount']); - - $address = $this->callAPISuccess('Address', 'get', array('contact_id' => $contribution['contact_id'], 'sequential' => TRUE)); - $this->assertEquals('2 Quacker Road', $address['values'][0]['street_address']); - $this->assertEquals('Duckville', $address['values'][0]['city']); - $this->assertEquals(90210, $address['values'][0]['postal_code']); - - $orgContributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $theRealDuck['id'])); - // The first row has no matching contribution. - $this->assertEquals(0, $orgContributions['count']); - - } - - /** - * Test a successful import run. - */ - function testImportSucceedAll() { - $mouseOrg = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); - $dogOrg = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Goofy Inc', 'contact_type' => 'Organization')); - $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Donald Duck Inc', 'contact_type' => 'Organization')); - $stingyOrg = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Uncle Scrooge Inc', 'contact_type' => 'Organization')); - - $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', 'employer_id' => $mouseOrg['id'], - )); - - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - - $contribution = $this->callAPISuccessGetSingle('Contribution', array('trxn_id' => 'BENEVITY trxn-WOOF')); - $this->assertEquals(22, $contribution['total_amount']); - $this->assertEquals(22, $contribution['net_amount']); - - // Our dog has very little details, a new contact will have been created for Pluto. - // It should have an address & a relationship & be soft-credited. - $dogContact = $this->callAPISuccessGetSingle('Contact', array('id' => $contribution['contact_id'])); - $dogContributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $dogContact['id'])); - $this->assertEquals(1, $dogContributions['count']); - $this->assertTrue(empty($dogContributions['values'][$dogContributions['id']]['soft_credit'])); - $dogHouse = $this->callAPISuccess('Address', 'get', array('contact_id' => $dogContact['id'], 'sequential' => 1)); - $this->assertEquals(1, $dogHouse['count']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $dogContact['id'])); - $this->assertEquals(1, $relationships['count']); - - $orgContributions = $this->callAPISuccess('Contribution', 'get', array('trxn_id' => 'BENEVITY TRXN-WOOF_MATCHED')); - // The first row has a matching contribution. - $this->assertEquals(1, $orgContributions['count']); - $this->assertEquals(25, $orgContributions['values'][$orgContributions['id']]['total_amount']); - $this->assertEquals(25, $orgContributions['values'][$orgContributions['id']]['net_amount']); - $this->assertEquals('Goofy Inc', $orgContributions['values'][$orgContributions['id']]['display_name']); - $this->assertEquals($dogContact['id'], $orgContributions['values'][$orgContributions['id']]['soft_credit_to']); - - $contribution = $this->callAPISuccess('Contribution', 'get', array('trxn_id' => 'BENEVITY TRXN-AARF')); - $this->assertEquals(0, $contribution['count']); - - $orgContributions = $this->callAPISuccess('Contribution', 'get', array('trxn_id' => 'BENEVITY TRXN-AARF_MATCHED')); - $this->assertEquals(1, $orgContributions['count']); - $this->assertEquals(.5, $orgContributions['values'][$orgContributions['id']]['total_amount']); - - // No address should have been created for the organization. - $organizationAddress = $this->callAPISuccess('Address', 'get', array( - 'contact_id' => $orgContributions['values'][$orgContributions['id']]['contact_id']) - ); - $this->assertEquals(0, $organizationAddress['count']); - - $anonymousContact = $this->callAPISuccessGetSingle('Contact', array('email' => 'fakeem...@wikimedia.org')); - $this->assertEquals('Anonymous', $anonymousContact['first_name']); - $this->assertEquals('Anonymous', $anonymousContact['last_name']); - // Let's not soft credit anonymouse. - $this->assertTrue(empty($orgContributions['values'][$orgContributions['id']]['soft_credit_to'])); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $anonymousContact['id'])); - $this->assertEquals(0, $relationships['count']); - - $mice = $this->callAPISuccess('Contact', 'get', array('first_name' => 'Minnie', 'last_name' => 'Mouse')); - $minnie = $mice['values'][$mice['id']]; - $this->assertEquals('2 Cheesey Place', $minnie['street_address']); - $this->assertEquals('Mickey Mouse Inc', $minnie['current_employer']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $minnie['id'])); - $this->assertEquals(1, $relationships['count']); - } - -} ->>>>>>> BRANCH (97c8df Merge "Benevity import, still create relationship when no in) diff --git a/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php deleted file mode 100644 index b2c70bd..0000000 --- a/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php +++ /dev/null @@ -1,84 +0,0 @@ -<<<<<<< HEAD (d20ed4 Merge master into deployment) -======= -<?php - -require_once __DIR__ . "/includes/BaseChecksFileTest.php"; - -/** - * @group Import - * @group Offline2Civicrm - */ -class ForeignChecksFileTest extends BaseChecksFileTest { - function setUp() { - parent::setUp(); - $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() { - civicrm_initialize(); - $importer = new ForeignChecksFile( __DIR__ . "/data/foreign_checks_trilogy.csv" ); - $importer->import(); - $messages = $importer->getMessages(); - $this->assertEquals('All rows were imported', $messages['Result']); - } - -} ->>>>>>> BRANCH (97c8df Merge "Benevity import, still create relationship when no in) diff --git a/sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv b/sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv deleted file mode 100644 index c06a645..0000000 --- a/sites/all/modules/offline2civicrm/tests/data/benevity_mice_no_email_matched_only.csv +++ /dev/null @@ -1,3 +0,0 @@ -Participating Corporation,Project,Date of Donation,Donor First Name,Donor Last Name,Email,Address,City,State/Province,Postal Code,Comment,Transaction ID,Donation Frequency,Donation Amount,Matched Amount,Total -Mickey Mouse Inc,,2015-11-02,Minnie,Mouse,Not shared by donor,Not shared by donor,Not shared by donor,Not shared by donor,90210,Very stingy,trxn-AARF,Recurring,0,0.5,10.5 -Mickey Mouse Inc,,2015-11-02,Not shared by donor,Mouse,Not shared by donor,Not shared by donor,Not shared by donor,Not shared by donor,90210,,trxn-PEEP,Recurring,0,10000.5,11500.5 diff --git a/sites/all/modules/offline2civicrm/tests/data/foreign_checks_trilogy.csv b/sites/all/modules/offline2civicrm/tests/data/foreign_checks_trilogy.csv deleted file mode 100644 index 1d580c3..0000000 --- a/sites/all/modules/offline2civicrm/tests/data/foreign_checks_trilogy.csv +++ /dev/null @@ -1,2 +0,0 @@ -Batch Number,Original Amount,Original Currency,Received Date,Payment Instrument,Check Number,First Name,Last Name,Street Address,Additional Address,City,State,Postal Code,Country,Email,Phone,No Thank You,Thank You Letter Date,Gift Source,Direct Mail Appeal,AC Flag,Restrictions,Notes,Do Not Email,Do Not Phone,Do Not Mail,Do Not SMS,Is Opt Out -,100,GBP,2/28/17 17:50,Trilogy,,Mickey,Mouse,First mousehole on the left,,London,England,MIC KEY,United Kingdom,mic...@mouse.com,,,,Community Gift,,,,,,,,, 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": "test...@wikimedia.org", - "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": "test+recur...@wikimedia.org", - "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 -} -- To view, visit https://gerrit.wikimedia.org/r/342155 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icfd0abbd599115efdefe96ab2fa01f23858d3765 Gerrit-PatchSet: 2 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: deployment Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org> Gerrit-Reviewer: Awight <awi...@wikimedia.org> Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org> Gerrit-Reviewer: Eileen <emcnaugh...@wikimedia.org> Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits