Ejegg has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/392553 )
Change subject: Align whitespace to drupal std. ...................................................................... Align whitespace to drupal std. I simply ran phpstorm code formatter over the offline2civicrm/tests dir with code formatting set to drupal standards & then eyeballed the changes as I committed them to see that nothing weird was happening. I thought that doing the files around the one I was about to start work on made sense Change-Id: Ic13a06b65f85fb007c9938dccf838cf59eb2ea61 --- M sites/all/modules/offline2civicrm/tests/BenevityTest.php M sites/all/modules/offline2civicrm/tests/ChecksFileTest.php M sites/all/modules/offline2civicrm/tests/CoinBaseTest.php M sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php M sites/all/modules/offline2civicrm/tests/EngageChecksFileTest.php M sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php M sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php M sites/all/modules/offline2civicrm/tests/PayPalChecksFileTest.php M sites/all/modules/offline2civicrm/tests/SquareFileTest.php M sites/all/modules/offline2civicrm/tests/WmfImportTest.php M sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php M sites/all/modules/offline2civicrm/tests/includes/ChecksFileProbe.php M sites/all/modules/offline2civicrm/tests/includes/EngageChecksFileProbe.php M sites/all/modules/offline2civicrm/tests/includes/ForeignChecksFileProbe.php M sites/all/modules/offline2civicrm/tests/includes/JpMorganFileProbe.php M sites/all/modules/offline2civicrm/tests/includes/PayPalChecksFileProbe.php M sites/all/modules/offline2civicrm/tests/includes/SquareFileProbe.php 17 files changed, 1,048 insertions(+), 812 deletions(-) Approvals: jenkins-bot: Verified Ejegg: Looks good to me, approved diff --git a/sites/all/modules/offline2civicrm/tests/BenevityTest.php b/sites/all/modules/offline2civicrm/tests/BenevityTest.php index 78487a5..8e1ff01 100644 --- a/sites/all/modules/offline2civicrm/tests/BenevityTest.php +++ b/sites/all/modules/offline2civicrm/tests/BenevityTest.php @@ -4,11 +4,13 @@ * @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 + * 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() { @@ -59,9 +61,15 @@ * 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" ); + $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']); @@ -71,7 +79,7 @@ * Test that all imports fail if the organization does not pre-exist. */ function testImportFailNoOrganizationContactExists() { - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $importer = new BenevityFile(__DIR__ . "/data/benevity.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('0 out of 4 rows were imported.', $messages['Result']); @@ -81,51 +89,73 @@ * 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" ); + $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. + * 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', + $thaMouseMeister = $this->callAPISuccess('Contact', 'create', array( + 'organization_name' => 'Mickey Mouse Inc', + 'contact_type' => 'Organization', )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $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'])); + $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. + * 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. + * 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" ); + $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']) + 'contact_id_a' => $contribution['contact_id'], + 'contact_id_b' => $thaMouseMeister['id'], + ) ); $this->assertEquals(1, $relationships['count']); - $minnie = $this->callAPISuccessGetSingle('Contact', array('id' => $contribution['contact_id'], 'return' => 'email')); + $minnie = $this->callAPISuccessGetSingle('Contact', array( + 'id' => $contribution['contact_id'], + 'return' => 'email', + )); $this->assertEquals('min...@mouse.org', $minnie['email']); } @@ -136,37 +166,51 @@ * 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')); + $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']) + 'contact_id_b' => $thaMouseMeister['id'], + ) ); $this->assertEquals(0, $relationships['count']); - $importer = new BenevityFile( __DIR__ . "/data/benevity_only_match.csv" ); + $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']) + 'contact_id_b' => $thaMouseMeister['id'], + ) ); - $this->assertEquals( $relationship['contact_id_a'], $contribution['soft_credit_to']); + $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. + * 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 + * 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. + * 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')); + $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' + '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( @@ -176,29 +220,41 @@ 'contact_id' => $thaMouseMeister['id'], )); - $importer = new BenevityFile( __DIR__ . "/data/benevity_only_match.csv" ); + $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']) + 'contact_id_b' => $thaMouseMeister['id'], + ) ); - $this->assertEquals( $relationship['contact_id_a'], $contribution['soft_credit_to']); + $this->assertEquals($relationship['contact_id_a'], $contribution['soft_credit_to']); } /** - * Test that import resolves ambiguous individuals by choosing based on the employer. + * 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')); + $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', + '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'], + '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 = new BenevityFile(__DIR__ . "/data/benevity.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); @@ -207,22 +263,34 @@ $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'])); + $relationships = $this->callAPISuccess('Relationship', 'get', array( + 'contact_id_a' => $betterMinnie['id'], + 'contact_id_b' => $organization['id'], + )); $this->assertEquals(1, $relationships['count']); } /** - * Test that import resolves ambiguous individuals by choosing based on the employer. + * Test that import resolves ambiguous individuals by choosing based on the + * employer. */ function testImportSucceedIndividualDisambiguateByEmployerEmailAdded() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); + $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', + 'first_name' => 'Minnie', + 'last_name' => 'Mouse', + 'contact_type' => 'Individual', )); $betterMinnie = $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'employer_id' => $organization['id'], + 'first_name' => 'Minnie', + 'last_name' => 'Mouse', + 'contact_type' => 'Individual', + 'employer_id' => $organization['id'], )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $importer = new BenevityFile(__DIR__ . "/data/benevity.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); @@ -231,23 +299,36 @@ $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'])); + $relationships = $this->callAPISuccess('Relationship', 'get', array( + 'contact_id_a' => $betterMinnie['id'], + 'contact_id_b' => $organization['id'], + )); $this->assertEquals(1, $relationships['count']); $this->callAPISuccessGetSingle('Email', array('email' => 'min...@mouse.org')); } /** - * Test that import creates new contacts when it can't resolve to a single contact. + * 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')); + $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', + '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', + 'first_name' => 'Minnie', + 'last_name' => 'Mouse', + 'contact_type' => 'Individual', + 'email' => 'min...@mouse.org', )); - $importer = new BenevityFile( __DIR__ . "/data/benevity_mice_no_email.csv" ); + $importer = new BenevityFile(__DIR__ . "/data/benevity_mice_no_email.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('All rows were imported', $messages['Result']); @@ -268,17 +349,29 @@ } /** - * Test that import resolves ambiguous individuals by choosing based on the employer where nick_name match in play. + * 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')); + $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', + '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'], + '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 = new BenevityFile(__DIR__ . "/data/benevity.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); @@ -290,20 +383,31 @@ } /** - * Test that import resolves ambiguous individuals based on previous soft credit history. + * 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. + * 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. + * 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')); + $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', + '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', + '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( @@ -312,7 +416,7 @@ 'soft_credit_to' => $betterMinnie['id'], 'contact_id' => $organization['id'], )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $importer = new BenevityFile(__DIR__ . "/data/benevity.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); @@ -321,24 +425,37 @@ $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'])); + $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 if there are multiple choices based on previous soft credit history. + * Test that import creates new if there are multiple choices based on + * previous soft credit history. * - * If we try to disambiguate our contact using soft credit history and there is more than - * one match, we give up & create a new one. In future this one should get used - * as it will have an employee relationship. + * If we try to disambiguate our contact using soft credit history and there + * is more than one match, we give up & create a new one. In future this one + * should get used as it will have an employee relationship. */ function testImportSucceedIndividualCreateIfAmbiguousPreviousSoftCredit() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); + $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', + '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', + 'first_name' => 'Minnie', + 'last_name' => 'Mouse', + 'contact_type' => 'Individual', + 'email' => 'min...@mouse.org', )); foreach (array($minnie, $betterMinnie) as $mouse) { // Create a contribution on the organisation, soft credited to each mouse.. @@ -350,11 +467,18 @@ )); } - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $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' => array('IN' => array($minnie['id'], $betterMinnie['id'])))); + $contributions = $this->callAPISuccess('Contribution', 'get', array( + 'contact_id' => array( + 'IN' => array( + $minnie['id'], + $betterMinnie['id'], + ), + ), + )); $this->assertEquals(0, $contributions['count']); $newestMouse = $this->callAPISuccessGetSingle('Contact', array( @@ -364,24 +488,39 @@ )); $contributions = $this->callAPISuccess('Contribution', 'get', array('contact_id' => $newestMouse['id'])); $this->assertEquals(1, $contributions['count']); - $relationships = $this->callAPISuccess('Relationship', 'get', array('contact_id_a' => $newestMouse['id'], 'contact_id_b' => $organization['id'])); + $relationships = $this->callAPISuccess('Relationship', 'get', array( + 'contact_id_a' => $newestMouse['id'], + 'contact_id_b' => $organization['id'], + )); $this->assertEquals(1, $relationships['count']); } /** - * Test that import resolves ambiguous individuals preferring relationships over soft credits. + * Test that import resolves ambiguous individuals preferring relationships + * over soft credits. * - * We resolve ambiguous contacts by choosing one previously linked to the employer. - * If there is more than one that is linked by 'is employed by' or 'has been previously - * soft credited' then we prefer the one with an employee relationship. + * We resolve ambiguous contacts by choosing one previously linked to the + * employer. If there is more than one that is linked by 'is employed by' or + * 'has been previously soft credited' then we prefer the one with an + * employee relationship. */ function testImportSucceedIndividualPreferRelationshipOverPreviousSoftCredit() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); + $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', + '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'], + 'first_name' => 'Minnie', + 'last_name' => 'Mouse', + 'contact_type' => 'Individual', + 'email' => 'min...@mouse.org', + 'employer_id' => $organization['id'], )); // Create a contribution on the organisation, soft credited to each minne. @@ -394,7 +533,7 @@ // But betterMinnie has a relationship, she wins. - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $importer = new BenevityFile(__DIR__ . "/data/benevity.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('1 out of 4 rows were imported.', $messages['Result']); @@ -405,28 +544,43 @@ } /** - * Test that we will accept a name match for employees, even when there is an email mis-match. + * 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. + * 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'], + $organization = $this->callAPISuccess('Contact', 'create', array( + 'organization_name' => 'Mickey Mouse Inc', + 'contact_type' => 'Organization', )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $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'])); + $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)); + $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']); @@ -435,21 +589,31 @@ } /** - * Check that without an email the match is accepted with an employer connection. + * 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')); + $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', + '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'], + '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 = new BenevityFile(__DIR__ . "/data/benevity_mice_no_email.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('All rows were imported', $messages['Result']); @@ -463,7 +627,7 @@ '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') + wmf_civicrm_get_custom_field_name('Campaign'), ), )); $this->assertEquals(2, $contributions['count']); @@ -484,7 +648,7 @@ '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') + wmf_civicrm_get_custom_field_name('Campaign'), ), )); foreach ($organizationContributions['values'] as $contribution) { @@ -500,12 +664,18 @@ * 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')); + $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', + 'first_name' => 'Minnie', + 'last_name' => 'Mouse', + 'contact_type' => 'Individual', + 'email' => 'min...@mouse.org', )); - $importer = new BenevityFile( __DIR__ . "/data/benevity_mice_no_email.csv" ); + $importer = new BenevityFile(__DIR__ . "/data/benevity_mice_no_email.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('All rows were imported', $messages['Result']); @@ -531,7 +701,10 @@ * contribution have also been rolled back. */ function testImportDuplicateFullRollback() { - $organization = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Mickey Mouse Inc', 'contact_type' => 'Organization')); + $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( @@ -540,35 +713,52 @@ 'total_amount' => 5, 'contact_id' => $organization['id'], )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $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')); + $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. + * 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. + * 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')); + $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 = 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)); + $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']); @@ -583,16 +773,32 @@ * 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')); - + $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( - 'first_name' => 'Minnie', 'last_name' => 'Mouse', 'contact_type' => 'Individual', 'email' => 'min...@mouse.org', 'employer_id' => $mouseOrg['id'], + 'organization_name' => 'Donald Duck Inc', + 'contact_type' => 'Organization', + )); + $stingyOrg = $this->callAPISuccess('Contact', 'create', array( + 'organization_name' => 'Uncle Scrooge Inc', + 'contact_type' => 'Organization', )); - $importer = new BenevityFile( __DIR__ . "/data/benevity.csv" ); + $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']); @@ -607,7 +813,10 @@ $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)); + $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']); @@ -629,7 +838,8 @@ // No address should have been created for the organization. $organizationAddress = $this->callAPISuccess('Address', 'get', array( - 'contact_id' => $orgContributions['values'][$orgContributions['id']]['contact_id']) + 'contact_id' => $orgContributions['values'][$orgContributions['id']]['contact_id'], + ) ); $this->assertEquals(0, $organizationAddress['count']); @@ -641,7 +851,10 @@ $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')); + $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']); diff --git a/sites/all/modules/offline2civicrm/tests/ChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/ChecksFileTest.php index 460c6a8..f33a3d9 100644 --- a/sites/all/modules/offline2civicrm/tests/ChecksFileTest.php +++ b/sites/all/modules/offline2civicrm/tests/ChecksFileTest.php @@ -5,63 +5,64 @@ * @group Offline2Civicrm */ class ChecksFileTest extends BaseChecksFileTest { - function setUp() { - parent::setUp(); - require_once __DIR__ . "/includes/ChecksFileProbe.php"; - } + function setUp() { + parent::setUp(); - /** - * @expectedException EmptyRowException - */ - function testEmptyRow() { - // A few kinds of empty. - $data = array( - 'Orignal Currency' => '', - '' => '700', - '' => '', - ); + require_once __DIR__ . "/includes/ChecksFileProbe.php"; + } - $importer = new ChecksFileProbe( "no URI" ); - $output = $importer->_parseRow( $data ); - } + /** + * @expectedException EmptyRowException + */ + function testEmptyRow() { + // A few kinds of empty. + $data = array( + 'Orignal Currency' => '', + '' => '700', + '' => '', + ); - /** - * Populate contribution_tracking.country - */ - function testImportCountry() { - // A few kinds of empty. - $data = array( - 'Check Number' => mt_rand(), - 'City' => 'blah city', - 'Country' => 'AR', - 'Email' => 'em...@phony.com', - 'External Batch Number' => mt_rand(), - 'First Name' => 'Test_first_name', - 'Gift Source' => 'Community GIft', - 'Last Name' => 'Test_last_name', - 'Original Amount' => '123', - 'Original Currency' => 'USD', - 'Payment Instrument' => 'Trilogy', - 'Postal Code' => '90210', - 'Postmark Date' => '2012-02-02', - 'Received Date' => '2017-07-07', - 'State' => 'CA', - 'Street Address' => '123 Sunset Boulevard', - 'Transaction ID' => mt_rand(), - ); + $importer = new ChecksFileProbe("no URI"); + $output = $importer->_parseRow($data); + } - $importer = new ChecksFileProbe( "no URI" ); - $message = $importer->_parseRow( $data ); - $importer->doImport( $message ); - $contribution = $this->callAPISuccessGetSingle( - 'Contribution', array( 'trxn_id' => "GENERIC_IMPORT {$data['Transaction ID']}" ) - ); - $ct = db_select( 'contribution_tracking', 'contribution_tracking' ) - ->fields( 'contribution_tracking' ) - ->condition( 'contribution_id', $contribution['id'] ) - ->execute() - ->fetchAssoc(); - $this->assertEquals( 'AR', $ct['country'] ); - } + /** + * Populate contribution_tracking.country + */ + function testImportCountry() { + // A few kinds of empty. + $data = array( + 'Check Number' => mt_rand(), + 'City' => 'blah city', + 'Country' => 'AR', + 'Email' => 'em...@phony.com', + 'External Batch Number' => mt_rand(), + 'First Name' => 'Test_first_name', + 'Gift Source' => 'Community GIft', + 'Last Name' => 'Test_last_name', + 'Original Amount' => '123', + 'Original Currency' => 'USD', + 'Payment Instrument' => 'Trilogy', + 'Postal Code' => '90210', + 'Postmark Date' => '2012-02-02', + 'Received Date' => '2017-07-07', + 'State' => 'CA', + 'Street Address' => '123 Sunset Boulevard', + 'Transaction ID' => mt_rand(), + ); + + $importer = new ChecksFileProbe("no URI"); + $message = $importer->_parseRow($data); + $importer->doImport($message); + $contribution = $this->callAPISuccessGetSingle( + 'Contribution', array('trxn_id' => "GENERIC_IMPORT {$data['Transaction ID']}") + ); + $ct = db_select('contribution_tracking', 'contribution_tracking') + ->fields('contribution_tracking') + ->condition('contribution_id', $contribution['id']) + ->execute() + ->fetchAssoc(); + $this->assertEquals('AR', $ct['country']); + } } diff --git a/sites/all/modules/offline2civicrm/tests/CoinBaseTest.php b/sites/all/modules/offline2civicrm/tests/CoinBaseTest.php index e7f9f78..0c71bbf 100644 --- a/sites/all/modules/offline2civicrm/tests/CoinBaseTest.php +++ b/sites/all/modules/offline2civicrm/tests/CoinBaseTest.php @@ -5,28 +5,29 @@ * @group Offline2Civicrm */ class CoinBaseTest extends BaseChecksFileTest { - protected $epochtime; - function setUp() { - parent::setUp(); + protected $epochtime; - $this->epochtime = wmf_common_date_parse_string('2016-09-15'); - $this->setExchangeRates($this->epochtime, array('USD' => 1, 'BTC' => 3)); - $this->gateway = 'coinbase'; - } + function setUp() { + parent::setUp(); - function testImport() { - civicrm_initialize(); - $this->trxn_id = 'Pluto'; - $this->doCleanUp(); + $this->epochtime = wmf_common_date_parse_string('2016-09-15'); + $this->setExchangeRates($this->epochtime, array('USD' => 1, 'BTC' => 3)); + $this->gateway = 'coinbase'; + } - $importer = new CoinbaseFile( __DIR__ . "/data/coinbase.csv" ); - $importer->import(); + function testImport() { + civicrm_initialize(); + $this->trxn_id = 'Pluto'; + $this->doCleanUp(); - $contribution = wmf_civicrm_get_contributions_from_gateway_id($this->gateway, $this->trxn_id); - $this->assertEquals(1, count($contribution)); - $this->assertEquals('COINBASE PLUTO', $contribution[0]['trxn_id']); - $this->assertEquals('online', db_query("SELECT {utm_medium} from {contribution_tracking} WHERE contribution_id = {$contribution[0]['id']}")->fetchField()); - } + $importer = new CoinbaseFile(__DIR__ . "/data/coinbase.csv"); + $importer->import(); + + $contribution = wmf_civicrm_get_contributions_from_gateway_id($this->gateway, $this->trxn_id); + $this->assertEquals(1, count($contribution)); + $this->assertEquals('COINBASE PLUTO', $contribution[0]['trxn_id']); + $this->assertEquals('online', db_query("SELECT {utm_medium} from {contribution_tracking} WHERE contribution_id = {$contribution[0]['id']}")->fetchField()); + } } diff --git a/sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php b/sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php index d6a91a0..4b06c09 100644 --- a/sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php +++ b/sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php @@ -2,61 +2,61 @@ class ContributionConversionTest extends BaseChecksFileTest { - public function setUp() { - parent::setUp(); - civicrm_initialize(); - // I'm slightly confused why this is required. phpunit is blowing away GLOBALS, - // including the one holding the DB connection but civicrm_initialize is not - // calling this on the second run due to the static being set. - // The reason this is confusing is logically, but not in practice, - // this test should be no more affected than other tests. - CRM_Core_Config::singleton(TRUE, TRUE); + public function setUp() { + parent::setUp(); + civicrm_initialize(); + // I'm slightly confused why this is required. phpunit is blowing away GLOBALS, + // including the one holding the DB connection but civicrm_initialize is not + // calling this on the second run due to the static being set. + // The reason this is confusing is logically, but not in practice, + // this test should be no more affected than other tests. + CRM_Core_Config::singleton(TRUE, TRUE); - $result = $this->callAPISuccess('Contact', 'create', array( - 'contact_type' => 'Individual', - 'email' => 'f...@example.com', - )); - $this->contact_id = $result['id']; + $result = $this->callAPISuccess('Contact', 'create', array( + 'contact_type' => 'Individual', + 'email' => 'f...@example.com', + )); + $this->contact_id = $result['id']; - $this->gateway_txn_id = "NaN-" . mt_rand(); - $this->transaction = WmfTransaction::from_unique_id( "GLOBALCOLLECT {$this->gateway_txn_id}" ); + $this->gateway_txn_id = "NaN-" . mt_rand(); + $this->transaction = WmfTransaction::from_unique_id("GLOBALCOLLECT {$this->gateway_txn_id}"); - $contributionResult = $this->callAPISuccess('Contribution', 'create', array( - 'contact_id' => $this->contact_id, - 'trxn_id' => $this->transaction->get_unique_id(), - 'contribution_type' => 'Cash', - 'total_amount' => '20.01', - 'receive_date' => wmf_common_date_unix_to_sql( time() ), - )); - $this->contribution_id = $contributionResult['id']; + $contributionResult = $this->callAPISuccess('Contribution', 'create', array( + 'contact_id' => $this->contact_id, + 'trxn_id' => $this->transaction->get_unique_id(), + 'contribution_type' => 'Cash', + 'total_amount' => '20.01', + 'receive_date' => wmf_common_date_unix_to_sql(time()), + )); + $this->contribution_id = $contributionResult['id']; - wmf_civicrm_set_custom_field_values($this->contribution_id, array( - 'original_amount' => '20.01', - 'original_currency' => 'USD', - )); - } + wmf_civicrm_set_custom_field_values($this->contribution_id, array( + 'original_amount' => '20.01', + 'original_currency' => 'USD', + )); + } - public function tearDown() { - parent::tearDown(); - $this->callAPISuccess('Contribution', 'delete', array('id' => $this->contribution_id)); - $this->callAPISuccess('Contact', 'delete', array('id' => $this->contact_id)); - } + public function tearDown() { + parent::tearDown(); + $this->callAPISuccess('Contribution', 'delete', array('id' => $this->contribution_id)); + $this->callAPISuccess('Contact', 'delete', array('id' => $this->contact_id)); + } - public function testMakeRecurring() { - ContributionConversion::makeRecurring( $this->transaction ); + public function testMakeRecurring() { + ContributionConversion::makeRecurring($this->transaction); - $contributions = wmf_civicrm_get_contributions_from_gateway_id( $this->transaction->gateway, $this->transaction->gateway_txn_id ); - $this->assertNotNull( $contributions[0]['contribution_recur_id'], - "Became a recurring contribution" ); - } + $contributions = wmf_civicrm_get_contributions_from_gateway_id($this->transaction->gateway, $this->transaction->gateway_txn_id); + $this->assertNotNull($contributions[0]['contribution_recur_id'], + "Became a recurring contribution"); + } - public function testMakeRecurringCancelled() { - ContributionConversion::makeRecurring( $this->transaction, true ); + public function testMakeRecurringCancelled() { + ContributionConversion::makeRecurring($this->transaction, TRUE); - $contributions = wmf_civicrm_get_contributions_from_gateway_id( $this->transaction->gateway, $this->transaction->gateway_txn_id ); + $contributions = wmf_civicrm_get_contributions_from_gateway_id($this->transaction->gateway, $this->transaction->gateway_txn_id); - $contribution_recur = $this->callAPISuccessGetSingle('ContributionRecur', array('id' => $contributions[0]['contribution_recur_id'])); - $this->assertNotNull( $contribution_recur['cancel_date'], - "Marked as cancelled" ); - } + $contribution_recur = $this->callAPISuccessGetSingle('ContributionRecur', array('id' => $contributions[0]['contribution_recur_id'])); + $this->assertNotNull($contribution_recur['cancel_date'], + "Marked as cancelled"); + } } diff --git a/sites/all/modules/offline2civicrm/tests/EngageChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/EngageChecksFileTest.php index d5287ad..acd4717 100644 --- a/sites/all/modules/offline2civicrm/tests/EngageChecksFileTest.php +++ b/sites/all/modules/offline2civicrm/tests/EngageChecksFileTest.php @@ -6,135 +6,136 @@ */ class EngageChecksFileTest extends BaseChecksFileTest { - protected $sourceFileUri = ''; - function setUp() { - parent::setUp(); + protected $sourceFileUri = ''; - require_once __DIR__ . "/includes/EngageChecksFileProbe.php"; - } + function setUp() { + parent::setUp(); - function testParseRow_Individual() { - $data = array( - 'Batch' => '1234', - 'Contribution Type' => 'Engage', - 'Total Amount' => '50', - 'Source' => 'USD 50.00', - 'Postmark Date' => '', - 'Received Date' => '4/1/14', - 'Payment Instrument' => 'Check', - 'Check Number' => '2020', - 'Restrictions' => 'Unrestricted - General', - 'Gift Source' => 'Community Gift', - 'Direct Mail Appeal' => 'White Mail', - 'Prefix' => 'Mrs.', - 'First Name' => 'Sub', - 'Last Name' => 'Tell', - 'Suffix' => '', - 'Street Address' => '1000 Markdown Markov', - 'Additional Address 1' => '', - 'Additional Address 2' => '', - 'City' => 'Best St. Louis', - 'State' => 'MA', - 'Postal Code' => '2468', - 'Country' => '', - 'Phone' => '(123) 456-0000', - 'Email' => '', - 'Thank You Letter Date' => '5/1/14', - 'AC Flag' => 'Y', - ); - $expected_normal = array( - 'check_number' => '2020', - 'city' => 'Best St. Louis', - 'contact_source' => 'check', - 'contact_type' => 'Individual', - 'contribution_source' => 'USD 50.00', - 'contribution_type' => 'engage', - 'country' => 'US', - 'currency' => 'USD', - 'date' => 1396310400, - 'direct_mail_appeal' => 'White Mail', - 'first_name' => 'Sub', - 'gateway' => 'engage', - 'gateway_txn_id' => 'e59ed825ea04516fb2abf1c130d47525', - 'gift_source' => 'Community Gift', - 'gross' => '50', - 'import_batch_number' => '1234', - 'last_name' => 'Tell', - 'name_prefix' => 'Mrs.', - 'payment_method' => 'Check', - 'postal_code' => '02468', - 'raw_contribution_type' => 'Engage', - 'restrictions' => 'Unrestricted - General', - 'state_province' => 'MA', - 'street_address' => '1000 Markdown Markov', - 'thankyou_date' => 1398902400, - ); + require_once __DIR__ . "/includes/EngageChecksFileProbe.php"; + } - $importer = new EngageChecksFileProbe( "null URI" ); - $output = $importer->_parseRow( $data ); + function testParseRow_Individual() { + $data = array( + 'Batch' => '1234', + 'Contribution Type' => 'Engage', + 'Total Amount' => '50', + 'Source' => 'USD 50.00', + 'Postmark Date' => '', + 'Received Date' => '4/1/14', + 'Payment Instrument' => 'Check', + 'Check Number' => '2020', + 'Restrictions' => 'Unrestricted - General', + 'Gift Source' => 'Community Gift', + 'Direct Mail Appeal' => 'White Mail', + 'Prefix' => 'Mrs.', + 'First Name' => 'Sub', + 'Last Name' => 'Tell', + 'Suffix' => '', + 'Street Address' => '1000 Markdown Markov', + 'Additional Address 1' => '', + 'Additional Address 2' => '', + 'City' => 'Best St. Louis', + 'State' => 'MA', + 'Postal Code' => '2468', + 'Country' => '', + 'Phone' => '(123) 456-0000', + 'Email' => '', + 'Thank You Letter Date' => '5/1/14', + 'AC Flag' => 'Y', + ); + $expected_normal = array( + 'check_number' => '2020', + 'city' => 'Best St. Louis', + 'contact_source' => 'check', + 'contact_type' => 'Individual', + 'contribution_source' => 'USD 50.00', + 'contribution_type' => 'engage', + 'country' => 'US', + 'currency' => 'USD', + 'date' => 1396310400, + 'direct_mail_appeal' => 'White Mail', + 'first_name' => 'Sub', + 'gateway' => 'engage', + 'gateway_txn_id' => 'e59ed825ea04516fb2abf1c130d47525', + 'gift_source' => 'Community Gift', + 'gross' => '50', + 'import_batch_number' => '1234', + 'last_name' => 'Tell', + 'name_prefix' => 'Mrs.', + 'payment_method' => 'Check', + 'postal_code' => '02468', + 'raw_contribution_type' => 'Engage', + 'restrictions' => 'Unrestricted - General', + 'state_province' => 'MA', + 'street_address' => '1000 Markdown Markov', + 'thankyou_date' => 1398902400, + ); - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } + $importer = new EngageChecksFileProbe("null URI"); + $output = $importer->_parseRow($data); - function testParseRow_Organization() { - $data = array( - 'Batch' => '1235', - 'Contribution Type' => 'Engage', - 'Total Amount' => '51.23', - 'Source' => 'USD 51.23', - 'Postmark Date' => '', - 'Received Date' => '4/1/14', - 'Payment Instrument' => 'Check', - 'Check Number' => '202000001', - 'Restrictions' => 'Restricted-Foundation', - 'Gift Source' => 'Foundation Gift', - 'Direct Mail Appeal' => 'White Mail', - 'Organization Name' => 'One Pacific Entitlement', - 'Street Address' => '1000 Markdown Markov', - 'Additional Address 1' => '', - 'Additional Address 2' => '', - 'City' => 'Best St. Louis', - 'State' => 'MA', - 'Postal Code' => '123-LAX', - 'Country' => 'FR', - 'Phone' => '+357 (123) 456-0000', - 'Email' => '', - 'Thank You Letter Date' => '5/1/14', - 'AC Flag' => '', - ); - $expected_normal = array( - 'check_number' => '202000001', - 'city' => 'Best St. Louis', - 'contact_source' => 'check', - 'contact_type' => 'Organization', - 'contribution_source' => 'USD 51.23', - 'contribution_type' => 'engage', - 'country' => 'FR', - 'currency' => 'USD', - 'date' => 1396310400, - 'direct_mail_appeal' => 'White Mail', - 'gateway' => 'engage', - 'gateway_txn_id' => '6dbb8d844c7509076e2a275fb76d0130', - 'gift_source' => 'Foundation Gift', - 'gross' => 51.23, - 'import_batch_number' => '1235', - 'organization_name' => 'One Pacific Entitlement', - 'payment_method' => 'Check', - 'postal_code' => '123-LAX', - 'raw_contribution_type' => 'Engage', - 'restrictions' => 'Restricted-Foundation', - 'state_province' => 'MA', - 'street_address' => '1000 Markdown Markov', - 'thankyou_date' => 1398902400, - ); + $this->stripSourceData($output); + $this->assertEquals($expected_normal, $output); + } - $importer = new EngageChecksFileProbe( "null URI" ); - $output = $importer->_parseRow( $data ); + function testParseRow_Organization() { + $data = array( + 'Batch' => '1235', + 'Contribution Type' => 'Engage', + 'Total Amount' => '51.23', + 'Source' => 'USD 51.23', + 'Postmark Date' => '', + 'Received Date' => '4/1/14', + 'Payment Instrument' => 'Check', + 'Check Number' => '202000001', + 'Restrictions' => 'Restricted-Foundation', + 'Gift Source' => 'Foundation Gift', + 'Direct Mail Appeal' => 'White Mail', + 'Organization Name' => 'One Pacific Entitlement', + 'Street Address' => '1000 Markdown Markov', + 'Additional Address 1' => '', + 'Additional Address 2' => '', + 'City' => 'Best St. Louis', + 'State' => 'MA', + 'Postal Code' => '123-LAX', + 'Country' => 'FR', + 'Phone' => '+357 (123) 456-0000', + 'Email' => '', + 'Thank You Letter Date' => '5/1/14', + 'AC Flag' => '', + ); + $expected_normal = array( + 'check_number' => '202000001', + 'city' => 'Best St. Louis', + 'contact_source' => 'check', + 'contact_type' => 'Organization', + 'contribution_source' => 'USD 51.23', + 'contribution_type' => 'engage', + 'country' => 'FR', + 'currency' => 'USD', + 'date' => 1396310400, + 'direct_mail_appeal' => 'White Mail', + 'gateway' => 'engage', + 'gateway_txn_id' => '6dbb8d844c7509076e2a275fb76d0130', + 'gift_source' => 'Foundation Gift', + 'gross' => 51.23, + 'import_batch_number' => '1235', + 'organization_name' => 'One Pacific Entitlement', + 'payment_method' => 'Check', + 'postal_code' => '123-LAX', + 'raw_contribution_type' => 'Engage', + 'restrictions' => 'Restricted-Foundation', + 'state_province' => 'MA', + 'street_address' => '1000 Markdown Markov', + 'thankyou_date' => 1398902400, + ); - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } + $importer = new EngageChecksFileProbe("null URI"); + $output = $importer->_parseRow($data); + + $this->stripSourceData($output); + $this->assertEquals($expected_normal, $output); + } public function testImporterFormatsPostal() { civicrm_initialize(); @@ -142,7 +143,10 @@ $importer = new EngageChecksFile($fileUri); $importer->import(); - $contact = $this->callAPISuccess('Contact', 'get', array('email' => 'rsimps...@unblog.fr', 'sequential' => 1)); + $contact = $this->callAPISuccess('Contact', 'get', array( + 'email' => 'rsimps...@unblog.fr', + 'sequential' => 1, + )); $this->assertEquals('07065', $contact['values'][0]['postal_code']); $this->assertEquals(5, strlen($contact['values'][0]['postal_code'])); } @@ -167,55 +171,55 @@ $this->fail('An exception should have been thrown'); } - public function testImporterCreatesOutputFiles() { - civicrm_initialize(); - $this->sourceFileUri = __DIR__ . '/../tests/data/engage_reduced.csv'; - $fileUri = $this->setupFile('engage_reduced.csv'); + public function testImporterCreatesOutputFiles() { + civicrm_initialize(); + $this->sourceFileUri = __DIR__ . '/../tests/data/engage_reduced.csv'; + $fileUri = $this->setupFile('engage_reduced.csv'); - $importer = new EngageChecksFile($fileUri); - $messages = $importer->import(); - global $user; - $this->assertEquals( - array ( - 0 => 'Successful import!', - 'Result' => '14 out of 18 rows were imported.', - 'not imported' => '4 not imported rows logged to <a href=\'/import_output/' . substr(str_replace('.csv', '_all_missed.' . $user->uid, $fileUri), 12) ."'> file</a>.", - 'Duplicate' => '1 Duplicate row logged to <a href=\'/import_output/' . substr(str_replace('.csv', '_skipped.' . $user->uid, $fileUri), 12) ."'> file</a>.", - 'Error' => '3 Error rows logged to <a href=\'/import_output/'. substr(str_replace('.csv', '_errors.' . $user->uid, $fileUri), 12) ."'> file</a>.", - ) - , $messages); + $importer = new EngageChecksFile($fileUri); + $messages = $importer->import(); + global $user; + $this->assertEquals( + array( + 0 => 'Successful import!', + 'Result' => '14 out of 18 rows were imported.', + 'not imported' => '4 not imported rows logged to <a href=\'/import_output/' . substr(str_replace('.csv', '_all_missed.' . $user->uid, $fileUri), 12) . "'> file</a>.", + 'Duplicate' => '1 Duplicate row logged to <a href=\'/import_output/' . substr(str_replace('.csv', '_skipped.' . $user->uid, $fileUri), 12) . "'> file</a>.", + 'Error' => '3 Error rows logged to <a href=\'/import_output/' . substr(str_replace('.csv', '_errors.' . $user->uid, $fileUri), 12) . "'> file</a>.", + ) + , $messages); - $errorsURI = str_replace('.csv', '_errors.' . $user->uid . '.csv', $fileUri); - $this->assertTrue(file_exists($errorsURI)); - $errors = file($errorsURI); + $errorsURI = str_replace('.csv', '_errors.' . $user->uid . '.csv', $fileUri); + $this->assertTrue(file_exists($errorsURI)); + $errors = file($errorsURI); - // Header row - $this->assertEquals('Error,Banner,Campaign,Medium,Batch,"Contribution Type","Total Amount",Source,"Postmark Date","Received Date","Payment Instrument","Check Number",Restrictions,"Gift Source","Direct Mail Appeal","Organization Name","Street Address",City,Country,"Postal Code",Email,State,"Thank You Letter Date","AC Flag",Notes,"Do Not Email","Do Not Phone","Do Not Mail","Do Not SMS","Is Opt Out"', trim($errors[0])); - unset($errors[0]); + // Header row + $this->assertEquals('Error,Banner,Campaign,Medium,Batch,"Contribution Type","Total Amount",Source,"Postmark Date","Received Date","Payment Instrument","Check Number",Restrictions,"Gift Source","Direct Mail Appeal","Organization Name","Street Address",City,Country,"Postal Code",Email,State,"Thank You Letter Date","AC Flag",Notes,"Do Not Email","Do Not Phone","Do Not Mail","Do Not SMS","Is Opt Out"', trim($errors[0])); + unset($errors[0]); - $this->assertEquals(3, count($errors)); - $this->assertEquals('"\'Unrstricted - General\' is not a valid option for field ' . wmf_civicrm_get_custom_field_name('Fund') . '",B15_0601_enlvroskLVROSK_dsk_lg_nag_sd.no-LP.cc,C15_mlWW_mob_lw_FR,sitenotice,10563,Engage,24,"USD 24.00",5/9/2015,5/9/2015,Cash,1,"Unrstricted - General","Corporate Gift","Carl TEST Perry",Roombo,"53 International Circle",Nowe,Poland,,cper...@salon.com,,12/21/2014,,,,,,, + $this->assertEquals(3, count($errors)); + $this->assertEquals('"\'Unrstricted - General\' is not a valid option for field ' . wmf_civicrm_get_custom_field_name('Fund') . '",B15_0601_enlvroskLVROSK_dsk_lg_nag_sd.no-LP.cc,C15_mlWW_mob_lw_FR,sitenotice,10563,Engage,24,"USD 24.00",5/9/2015,5/9/2015,Cash,1,"Unrstricted - General","Corporate Gift","Carl TEST Perry",Roombo,"53 International Circle",Nowe,Poland,,cper...@salon.com,,12/21/2014,,,,,,, ', $errors[1]); - $skippedURI = str_replace('.csv', '_skipped.' . $user->uid . '.csv', $fileUri); - $this->assertTrue(file_exists($skippedURI)); - $skipped = file($skippedURI); - // 1 + 1 header row - $this->assertEquals(2, count($skipped)); + $skippedURI = str_replace('.csv', '_skipped.' . $user->uid . '.csv', $fileUri); + $this->assertTrue(file_exists($skippedURI)); + $skipped = file($skippedURI); + // 1 + 1 header row + $this->assertEquals(2, count($skipped)); - $allURI = str_replace('.csv', '_all_missed.' . $user->uid . '.csv', $fileUri); - $this->assertTrue(file_exists($allURI)); - $all = file($allURI); - // 1 header row, 1 skipped, 3 errors. - $this->assertEquals(5, count($all)); + $allURI = str_replace('.csv', '_all_missed.' . $user->uid . '.csv', $fileUri); + $this->assertTrue(file_exists($allURI)); + $all = file($allURI); + // 1 header row, 1 skipped, 3 errors. + $this->assertEquals(5, count($all)); - } + } /** * Clean up transactions from previous test runs. * - * If you run this several times locally it will fail on duplicate transactions - * if we don't clean them up first. + * If you run this several times locally it will fail on duplicate + * transactions if we don't clean them up first. */ public function purgePreviousData() { $this->callAPISuccess('Contribution', 'get', array( @@ -226,39 +230,39 @@ CRM_Core_DAO::executeQuery('DELETE FROM civicrm_contact WHERE organization_name = "Jaloo"'); } - /** - * Get the gateway IDS from the source file. - */ - public function getGatewayIDs() { - $gatewayIDs = array(); - $data = $this->getParsedData(); - foreach ($data as $record) { - $gatewayIDs[] = $record['gateway_txn_id']; - } - return $gatewayIDs; + /** + * Get the gateway IDS from the source file. + */ + public function getGatewayIDs() { + $gatewayIDs = array(); + $data = $this->getParsedData(); + foreach ($data as $record) { + $gatewayIDs[] = $record['gateway_txn_id']; } + return $gatewayIDs; + } - /** - * Get parsed data from the source file. - * - * @return array - */ - public function getParsedData() { - $file = fopen($this->sourceFileUri, 'r'); - $result = array(); - $importer = new EngageChecksFileProbe( "null URI" ); - while(($row = fgetcsv( $file, 0, ',', '"', '\\')) !== FALSE) { - if ($row[0] == 'Banner') { - // Header row. - $headers = _load_headers($row); - continue; - } - $data = array_combine(array_keys($headers), array_slice($row, 0, count($headers))); - $result[] = $importer->_parseRow($data); - + /** + * Get parsed data from the source file. + * + * @return array + */ + public function getParsedData() { + $file = fopen($this->sourceFileUri, 'r'); + $result = array(); + $importer = new EngageChecksFileProbe("null URI"); + while (($row = fgetcsv($file, 0, ',', '"', '\\')) !== FALSE) { + if ($row[0] == 'Banner') { + // Header row. + $headers = _load_headers($row); + continue; } - return $result; + $data = array_combine(array_keys($headers), array_slice($row, 0, count($headers))); + $result[] = $importer->_parseRow($data); + } + return $result; + } /** * Set up the file for import. diff --git a/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php index 566b9fc..f88a824 100644 --- a/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php +++ b/sites/all/modules/offline2civicrm/tests/ForeignChecksFileTest.php @@ -7,72 +7,73 @@ * @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 setUp() { + parent::setUp(); + civicrm_initialize(); + $this->epochtime = wmf_common_date_parse_string('2017-02-28'); + $this->setExchangeRates($this->epochtime, array('USD' => 1, 'GBP' => 2)); - 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', - ); + require_once __DIR__ . "/includes/ForeignChecksFileProbe.php"; + } - $importer = new ForeignChecksFileProbe( "null URI" ); - $output = $importer->_parseRow( $data ); + 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', + ); - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } + $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 = new ForeignChecksFile(__DIR__ . "/data/foreign_checks_trilogy.csv"); $importer->import(); $messages = $importer->getMessages(); $this->assertEquals('All rows were imported', $messages['Result']); diff --git a/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php b/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php index c949e77..411075c 100644 --- a/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php +++ b/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php @@ -5,86 +5,91 @@ * @group Offline2Civicrm */ class JpMorganFileTest extends BaseChecksFileTest { - protected $epochtime; - protected $strtime; - function setUp() { - parent::setUp(); + protected $epochtime; - require_once __DIR__ . "/includes/JpMorganFileProbe.php"; + protected $strtime; - $this->strtime = '04/02/2000'; - $this->epochtime = wmf_common_date_parse_string('2000-04-02'); - $this->setExchangeRates( $this->epochtime, array( 'USD' => 1, 'EUR' => 3 ) ); - $this->gateway = 'jpmorgan'; - } + function setUp() { + parent::setUp(); - function testParseRow() { - $data = array( - 'Account Name' => 'Testes EUR_Public', - 'Currency' => 'EUR', - 'Customer Reference' => 'UNAVAILABLE', - 'Bank Reference' => '1234TEST', - 'Transaction Date' => '04/01/2000', - 'Description' => 'FOO CREDIT RECEIVED', - 'Value Date' => $this->strtime, - 'Credit Amount' => '5.50', - ); - $expected_normal = array( - 'contact_source' => 'check', - 'contact_type' => 'Individual', - 'country' => 'US', - 'currency' => 'EUR', - 'date' => 954547200, - 'direct_mail_appeal' => 'White Mail', - 'email' => 'nob...@wikimedia.org', - 'gateway_account' => 'Testes EUR_Public', - 'gateway' => 'jpmorgan', - 'gateway_txn_id' => '1234TEST', - 'gift_source' => 'Community Gift', - 'gross' => '5.50', - 'no_thank_you' => 'No Contact Details', - 'payment_instrument' => 'JP Morgan EUR', - 'restrictions' => 'Unrestricted - General', - 'settlement_date' => $this->epochtime, - ); + require_once __DIR__ . "/includes/JpMorganFileProbe.php"; - $importer = new JpMorganFileProbe( "no URI" ); - $output = $importer->_parseRow( $data ); + $this->strtime = '04/02/2000'; + $this->epochtime = wmf_common_date_parse_string('2000-04-02'); + $this->setExchangeRates($this->epochtime, array('USD' => 1, 'EUR' => 3)); + $this->gateway = 'jpmorgan'; + } - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } + function testParseRow() { + $data = array( + 'Account Name' => 'Testes EUR_Public', + 'Currency' => 'EUR', + 'Customer Reference' => 'UNAVAILABLE', + 'Bank Reference' => '1234TEST', + 'Transaction Date' => '04/01/2000', + 'Description' => 'FOO CREDIT RECEIVED', + 'Value Date' => $this->strtime, + 'Credit Amount' => '5.50', + ); + $expected_normal = array( + 'contact_source' => 'check', + 'contact_type' => 'Individual', + 'country' => 'US', + 'currency' => 'EUR', + 'date' => 954547200, + 'direct_mail_appeal' => 'White Mail', + 'email' => 'nob...@wikimedia.org', + 'gateway_account' => 'Testes EUR_Public', + 'gateway' => 'jpmorgan', + 'gateway_txn_id' => '1234TEST', + 'gift_source' => 'Community Gift', + 'gross' => '5.50', + 'no_thank_you' => 'No Contact Details', + 'payment_instrument' => 'JP Morgan EUR', + 'restrictions' => 'Unrestricted - General', + 'settlement_date' => $this->epochtime, + ); - function testImport() { - //FIXME - $_GET['q'] = ''; - civicrm_initialize(); - $this->trxn_id = '1234TEST'; - $this->doCleanUp(); + $importer = new JpMorganFileProbe("no URI"); + $output = $importer->_parseRow($data); - $this->setExchangeRates( wmf_common_date_parse_string( '2000-04-01' ), array( 'USD' => 1, 'EUR' => 3 ) ); + $this->stripSourceData($output); + $this->assertEquals($expected_normal, $output); + } - $importer = new JpMorganFileProbe( __DIR__ . "/data/jpmorgan.csv" ); - $importer->import(); + function testImport() { + //FIXME + $_GET['q'] = ''; + civicrm_initialize(); + $this->trxn_id = '1234TEST'; + $this->doCleanUp(); - $contribution = wmf_civicrm_get_contributions_from_gateway_id( 'jpmorgan', '1234TEST' ); - $this->assertEquals( 1, count( $contribution ) ); - $this->assertEquals( 'JPMORGAN 1234TEST', $contribution[0]['trxn_id'] ); - } + $this->setExchangeRates(wmf_common_date_parse_string('2000-04-01'), array( + 'USD' => 1, + 'EUR' => 3, + )); - /** - * @expectedException WmfException - * @expectedExceptionCode WmfException::INVALID_FILE_FORMAT - * @expectedExceptionMessage Duplicate column headers: CURRENCY, reference - */ - function testImportDuplicateHeaders() { - //FIXME - $_GET['q'] = ''; - //FIXME - civicrm_initialize(); + $importer = new JpMorganFileProbe(__DIR__ . "/data/jpmorgan.csv"); + $importer->import(); - $importer = new JpMorganFileProbe( __DIR__ . "/data/duplicate_header.csv" ); - $importer->import(); - } + $contribution = wmf_civicrm_get_contributions_from_gateway_id('jpmorgan', '1234TEST'); + $this->assertEquals(1, count($contribution)); + $this->assertEquals('JPMORGAN 1234TEST', $contribution[0]['trxn_id']); + } + + /** + * @expectedException WmfException + * @expectedExceptionCode WmfException::INVALID_FILE_FORMAT + * @expectedExceptionMessage Duplicate column headers: CURRENCY, reference + */ + function testImportDuplicateHeaders() { + //FIXME + $_GET['q'] = ''; + //FIXME + civicrm_initialize(); + + $importer = new JpMorganFileProbe(__DIR__ . "/data/duplicate_header.csv"); + $importer->import(); + } } diff --git a/sites/all/modules/offline2civicrm/tests/PayPalChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/PayPalChecksFileTest.php index 8535bca..e25af1f 100644 --- a/sites/all/modules/offline2civicrm/tests/PayPalChecksFileTest.php +++ b/sites/all/modules/offline2civicrm/tests/PayPalChecksFileTest.php @@ -5,60 +5,61 @@ * @group Offline2Civicrm */ class PayPalChecksFileTest extends BaseChecksFileTest { - function setUp() { - parent::setUp(); - require_once __DIR__ . "/includes/PayPalChecksFileProbe.php"; - } + function setUp() { + parent::setUp(); - function testParseRow() { - $data = array( - 'Contribution Type' => 'Cash', - 'Total Amount' => '$10.00', - 'Source' => 'USD 10.00', - 'Received Date' => '1/27/13', - 'Payment Instrument' => 'EFT', - 'Restrictions' => 'Unrestricted - General', - 'Gift Source' => 'Community Gift', - 'Direct Mail Appeal' => 'MissionFish (PayPal)', - 'Prefix' => '', - 'First Name' => 'Diz and', - 'Last Name' => 'Bird', - 'Suffix' => '', - 'Street Address' => '', - 'Additional Address 1' => '', - 'Additional Address 2' => '', - 'City' => '', - 'State' => '', - 'Postal Code' => '', - 'Country' => '', - 'Phone' => '', - 'Email' => '', - 'No Thank You' => 'no reas', - ); - $expected_normal = array( - 'contact_source' => 'check', - 'contact_type' => 'Individual', - 'contribution_source' => 'USD 10.00', - 'country' => 'US', - 'currency' => 'USD', - 'date' => '1/27/13', - 'direct_mail_appeal' => 'MissionFish (PayPal)', - 'first_name' => 'Diz and', - 'gateway' => 'paypal', - 'gift_source' => 'Community Gift', - 'gross' => '$10.00', - 'last_name' => 'Bird', - 'no_thank_you' => 'no reas', - 'payment_method' => 'EFT', - 'raw_contribution_type' => 'Cash', - 'restrictions' => 'Unrestricted - General', - ); + require_once __DIR__ . "/includes/PayPalChecksFileProbe.php"; + } - $importer = new PayPalChecksFileProbe( "no URI" ); - $output = $importer->_parseRow( $data ); + function testParseRow() { + $data = array( + 'Contribution Type' => 'Cash', + 'Total Amount' => '$10.00', + 'Source' => 'USD 10.00', + 'Received Date' => '1/27/13', + 'Payment Instrument' => 'EFT', + 'Restrictions' => 'Unrestricted - General', + 'Gift Source' => 'Community Gift', + 'Direct Mail Appeal' => 'MissionFish (PayPal)', + 'Prefix' => '', + 'First Name' => 'Diz and', + 'Last Name' => 'Bird', + 'Suffix' => '', + 'Street Address' => '', + 'Additional Address 1' => '', + 'Additional Address 2' => '', + 'City' => '', + 'State' => '', + 'Postal Code' => '', + 'Country' => '', + 'Phone' => '', + 'Email' => '', + 'No Thank You' => 'no reas', + ); + $expected_normal = array( + 'contact_source' => 'check', + 'contact_type' => 'Individual', + 'contribution_source' => 'USD 10.00', + 'country' => 'US', + 'currency' => 'USD', + 'date' => '1/27/13', + 'direct_mail_appeal' => 'MissionFish (PayPal)', + 'first_name' => 'Diz and', + 'gateway' => 'paypal', + 'gift_source' => 'Community Gift', + 'gross' => '$10.00', + 'last_name' => 'Bird', + 'no_thank_you' => 'no reas', + 'payment_method' => 'EFT', + 'raw_contribution_type' => 'Cash', + 'restrictions' => 'Unrestricted - General', + ); - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } + $importer = new PayPalChecksFileProbe("no URI"); + $output = $importer->_parseRow($data); + + $this->stripSourceData($output); + $this->assertEquals($expected_normal, $output); + } } diff --git a/sites/all/modules/offline2civicrm/tests/SquareFileTest.php b/sites/all/modules/offline2civicrm/tests/SquareFileTest.php index 0f201fc..50314de 100644 --- a/sites/all/modules/offline2civicrm/tests/SquareFileTest.php +++ b/sites/all/modules/offline2civicrm/tests/SquareFileTest.php @@ -5,89 +5,90 @@ * @group Offline2Civicrm */ class SquareFileTest extends BaseChecksFileTest { - function setUp() { - parent::setUp(); - require_once __DIR__ . "/includes/SquareFileProbe.php"; - } + function setUp() { + parent::setUp(); - function testParseRow() { - $data = array( - 'Currency' => 'USD', - 'Email Address' => 'm...@gmail.com', - 'Gross Amount' => '$35.00', - 'Name' => 'Max Normal', - 'Net Amount' => '$35.00', - 'Payment ID' => 'abc123', - 'Phone Number' => '3333333333', - 'Status' => 'Completed', - 'Timestamp' => 1426129877, - 'Zip Code' => '94103', - ); - $expected_normal = array( - 'contact_source' => 'check', - 'contact_type' => 'Individual', - 'contribution_type' => 'cash', - 'country' => 'US', - 'currency' => 'USD', - 'date' => 1426129877, - 'email' => 'm...@gmail.com', - 'first_name' => 'Max', - 'full_name' => 'Max Normal', - 'gateway' => 'square', - 'gateway_status_raw' => 'Completed', - 'gateway_txn_id' => 'abc123', - 'gross' => '35.00', - 'last_name' => 'Normal', - 'net' => '35.00', - 'phone' => '3333333333', - 'postal_code' => '94103', - ); + require_once __DIR__ . "/includes/SquareFileProbe.php"; + } - $importer = new SquareFileProbe( "no URI" ); - $output = $importer->_parseRow( $data ); + function testParseRow() { + $data = array( + 'Currency' => 'USD', + 'Email Address' => 'm...@gmail.com', + 'Gross Amount' => '$35.00', + 'Name' => 'Max Normal', + 'Net Amount' => '$35.00', + 'Payment ID' => 'abc123', + 'Phone Number' => '3333333333', + 'Status' => 'Completed', + 'Timestamp' => 1426129877, + 'Zip Code' => '94103', + ); + $expected_normal = array( + 'contact_source' => 'check', + 'contact_type' => 'Individual', + 'contribution_type' => 'cash', + 'country' => 'US', + 'currency' => 'USD', + 'date' => 1426129877, + 'email' => 'm...@gmail.com', + 'first_name' => 'Max', + 'full_name' => 'Max Normal', + 'gateway' => 'square', + 'gateway_status_raw' => 'Completed', + 'gateway_txn_id' => 'abc123', + 'gross' => '35.00', + 'last_name' => 'Normal', + 'net' => '35.00', + 'phone' => '3333333333', + 'postal_code' => '94103', + ); - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } + $importer = new SquareFileProbe("no URI"); + $output = $importer->_parseRow($data); - function testParseRow_Refund() { - $data = array( - 'Currency' => 'USD', - 'Email Address' => 'm...@gmail.com', - 'Gross Amount' => '$35.00', - 'Name' => 'Max Normal', - 'Net Amount' => '$0', - 'Payment ID' => 'abc123', - 'Phone Number' => '3333333333', - 'Status' => 'Refunded', - 'Timestamp' => 1426129877, - 'Zip Code' => '94103', - ); - $expected_normal = array( - 'contact_source' => 'check', - 'contact_type' => 'Individual', - 'contribution_type' => 'cash', - 'country' => 'US', - 'currency' => 'USD', - 'date' => 1426129877, - 'email' => 'm...@gmail.com', - 'first_name' => 'Max', - 'full_name' => 'Max Normal', - 'gateway' => 'square', - 'gateway_status_raw' => 'Refunded', - 'gateway_txn_id' => 'abc123', - 'gross' => '35.00', - 'last_name' => 'Normal', - 'net' => '35.00', - 'phone' => '3333333333', - 'postal_code' => '94103', - ); + $this->stripSourceData($output); + $this->assertEquals($expected_normal, $output); + } - $importer = new SquareFileProbe( "no URI" ); - $output = $importer->_parseRow( $data ); + function testParseRow_Refund() { + $data = array( + 'Currency' => 'USD', + 'Email Address' => 'm...@gmail.com', + 'Gross Amount' => '$35.00', + 'Name' => 'Max Normal', + 'Net Amount' => '$0', + 'Payment ID' => 'abc123', + 'Phone Number' => '3333333333', + 'Status' => 'Refunded', + 'Timestamp' => 1426129877, + 'Zip Code' => '94103', + ); + $expected_normal = array( + 'contact_source' => 'check', + 'contact_type' => 'Individual', + 'contribution_type' => 'cash', + 'country' => 'US', + 'currency' => 'USD', + 'date' => 1426129877, + 'email' => 'm...@gmail.com', + 'first_name' => 'Max', + 'full_name' => 'Max Normal', + 'gateway' => 'square', + 'gateway_status_raw' => 'Refunded', + 'gateway_txn_id' => 'abc123', + 'gross' => '35.00', + 'last_name' => 'Normal', + 'net' => '35.00', + 'phone' => '3333333333', + 'postal_code' => '94103', + ); - $this->stripSourceData( $output ); - $this->assertEquals( $expected_normal, $output ); - } + $importer = new SquareFileProbe("no URI"); + $output = $importer->_parseRow($data); + + $this->stripSourceData($output); + $this->assertEquals($expected_normal, $output); + } } diff --git a/sites/all/modules/offline2civicrm/tests/WmfImportTest.php b/sites/all/modules/offline2civicrm/tests/WmfImportTest.php index b1f480c..e98fa6b 100644 --- a/sites/all/modules/offline2civicrm/tests/WmfImportTest.php +++ b/sites/all/modules/offline2civicrm/tests/WmfImportTest.php @@ -8,56 +8,56 @@ */ class WmfImportTest extends BaseChecksFileTest { - /** - * Existing contribution_tracking row is updated with contribution_id - */ - function testImportExistingTracking() { - $contribution_tracking_id = wmf_civicrm_insert_contribution_tracking( array( - 'utm_source' => 'Blah_source', - 'utm_medium' => 'civicrm', - 'utm_campaign' => 'test_campaign', - 'ts' => wmf_common_date_unix_to_sql( time() ) - ) ); + /** + * Existing contribution_tracking row is updated with contribution_id + */ + function testImportExistingTracking() { + $contribution_tracking_id = wmf_civicrm_insert_contribution_tracking(array( + 'utm_source' => 'Blah_source', + 'utm_medium' => 'civicrm', + 'utm_campaign' => 'test_campaign', + 'ts' => wmf_common_date_unix_to_sql(time()), + )); - $this->trxn_id = mt_rand(); - $this->gateway = 'globalcollect'; - $data = array( - 'City' => 'blah city', - 'Contribution Tracking ID' => $contribution_tracking_id, - 'Country' => 'AR', - 'Email' => 'em...@phony.com', - 'External Batch Number' => mt_rand(), - 'First Name' => 'Test_first_name', - 'Gift Source' => 'Community GIft', - 'Last Name' => 'Test_last_name', - 'Original Amount' => '123', - 'Original Currency' => 'USD', - 'Payment Gateway' => $this->gateway, - 'Payment Instrument' => 'Cash', - 'Postal Code' => '90210', - 'Postmark Date' => '2012-02-02', - 'Received Date' => '2017-07-07', - 'State' => 'CA', - 'Street Address' => '123 Sunset Boulevard', - 'Transaction ID' => $this->trxn_id, - ); - $importer = new WmfImportFile( "no URI" ); - $exposed = TestingAccessWrapper::newFromObject( $importer ); - $message = $exposed->parseRow( $data ); - $exposed->doImport( $message ); - $contributions = wmf_civicrm_get_contributions_from_gateway_id( - $this->gateway, $this->trxn_id - ); - $this->assertEquals( 1, count( $contributions ) ); - $contribution = $contributions[0]; - $this->assertEquals( $this->gateway, $contribution['gateway'] ); - $ct = db_select( 'contribution_tracking', 'contribution_tracking' ) - ->fields( 'contribution_tracking' ) - ->condition( 'id', $contribution_tracking_id ) - ->execute() - ->fetchAssoc(); - $this->assertEquals( $contribution['id'], $ct['contribution_id'] ); - // TODO: should update existing c_t row with country! - // $this->assertEquals( 'AR', $ct['country'] ); - } + $this->trxn_id = mt_rand(); + $this->gateway = 'globalcollect'; + $data = array( + 'City' => 'blah city', + 'Contribution Tracking ID' => $contribution_tracking_id, + 'Country' => 'AR', + 'Email' => 'em...@phony.com', + 'External Batch Number' => mt_rand(), + 'First Name' => 'Test_first_name', + 'Gift Source' => 'Community GIft', + 'Last Name' => 'Test_last_name', + 'Original Amount' => '123', + 'Original Currency' => 'USD', + 'Payment Gateway' => $this->gateway, + 'Payment Instrument' => 'Cash', + 'Postal Code' => '90210', + 'Postmark Date' => '2012-02-02', + 'Received Date' => '2017-07-07', + 'State' => 'CA', + 'Street Address' => '123 Sunset Boulevard', + 'Transaction ID' => $this->trxn_id, + ); + $importer = new WmfImportFile("no URI"); + $exposed = TestingAccessWrapper::newFromObject($importer); + $message = $exposed->parseRow($data); + $exposed->doImport($message); + $contributions = wmf_civicrm_get_contributions_from_gateway_id( + $this->gateway, $this->trxn_id + ); + $this->assertEquals(1, count($contributions)); + $contribution = $contributions[0]; + $this->assertEquals($this->gateway, $contribution['gateway']); + $ct = db_select('contribution_tracking', 'contribution_tracking') + ->fields('contribution_tracking') + ->condition('id', $contribution_tracking_id) + ->execute() + ->fetchAssoc(); + $this->assertEquals($contribution['id'], $ct['contribution_id']); + // TODO: should update existing c_t row with country! + // $this->assertEquals( 'AR', $ct['country'] ); + } } diff --git a/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php b/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php index 57ee4d2..3060584 100644 --- a/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php +++ b/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php @@ -1,6 +1,7 @@ <?php class BaseChecksFileTest extends BaseWmfDrupalPhpUnitTestCase { + /** * Gateway. * @@ -8,63 +9,65 @@ * * @var string */ - protected $gateway; + protected $gateway; /** - * Transaction id being worked with. This is combined with the gateway for the civi trxn_id. + * 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'] ); + protected $trxn_id; - 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'] ); - } + /** + * 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(); - } + 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'])); - } + /** + * 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(); } + $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'); - } + /** + * 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'); + } } diff --git a/sites/all/modules/offline2civicrm/tests/includes/ChecksFileProbe.php b/sites/all/modules/offline2civicrm/tests/includes/ChecksFileProbe.php index cbf8be7..4e6d4ae 100644 --- a/sites/all/modules/offline2civicrm/tests/includes/ChecksFileProbe.php +++ b/sites/all/modules/offline2civicrm/tests/includes/ChecksFileProbe.php @@ -2,15 +2,16 @@ /** TODO: Use a generalized access wrapper instead. */ class ChecksFileProbe extends ChecksFile { - function _parseRow( $data ) { - return $this->parseRow( $data ); - } - protected function getRequiredColumns() { - return array(); - } + function _parseRow($data) { + return $this->parseRow($data); + } - protected function getRequiredData() { - return array(); - } + protected function getRequiredColumns() { + return array(); + } + + protected function getRequiredData() { + return array(); + } } diff --git a/sites/all/modules/offline2civicrm/tests/includes/EngageChecksFileProbe.php b/sites/all/modules/offline2civicrm/tests/includes/EngageChecksFileProbe.php index 5e9765b..50a8c73 100644 --- a/sites/all/modules/offline2civicrm/tests/includes/EngageChecksFileProbe.php +++ b/sites/all/modules/offline2civicrm/tests/includes/EngageChecksFileProbe.php @@ -1,7 +1,8 @@ <?php class EngageChecksFileProbe extends EngageChecksFile { - function _parseRow( $data ) { - return $this->parseRow( $data ); - } + + function _parseRow($data) { + return $this->parseRow($data); + } } diff --git a/sites/all/modules/offline2civicrm/tests/includes/ForeignChecksFileProbe.php b/sites/all/modules/offline2civicrm/tests/includes/ForeignChecksFileProbe.php index 153e96a..6076a37 100644 --- a/sites/all/modules/offline2civicrm/tests/includes/ForeignChecksFileProbe.php +++ b/sites/all/modules/offline2civicrm/tests/includes/ForeignChecksFileProbe.php @@ -1,7 +1,8 @@ <?php class ForeignChecksFileProbe extends ForeignChecksFile { - function _parseRow( $data ) { - return $this->parseRow( $data ); - } + + function _parseRow($data) { + return $this->parseRow($data); + } } diff --git a/sites/all/modules/offline2civicrm/tests/includes/JpMorganFileProbe.php b/sites/all/modules/offline2civicrm/tests/includes/JpMorganFileProbe.php index 7dac60d..4add613 100644 --- a/sites/all/modules/offline2civicrm/tests/includes/JpMorganFileProbe.php +++ b/sites/all/modules/offline2civicrm/tests/includes/JpMorganFileProbe.php @@ -1,7 +1,8 @@ <?php class JpMorganFileProbe extends JpMorganFile { - function _parseRow( $data ) { - return $this->parseRow( $data ); - } + + function _parseRow($data) { + return $this->parseRow($data); + } } diff --git a/sites/all/modules/offline2civicrm/tests/includes/PayPalChecksFileProbe.php b/sites/all/modules/offline2civicrm/tests/includes/PayPalChecksFileProbe.php index c35352f..e47fc80 100644 --- a/sites/all/modules/offline2civicrm/tests/includes/PayPalChecksFileProbe.php +++ b/sites/all/modules/offline2civicrm/tests/includes/PayPalChecksFileProbe.php @@ -1,7 +1,8 @@ <?php class PayPalChecksFileProbe extends PayPalChecksFile { - function _parseRow( $data ) { - return $this->parseRow( $data ); - } + + function _parseRow($data) { + return $this->parseRow($data); + } } diff --git a/sites/all/modules/offline2civicrm/tests/includes/SquareFileProbe.php b/sites/all/modules/offline2civicrm/tests/includes/SquareFileProbe.php index 7d61b26..1744487 100644 --- a/sites/all/modules/offline2civicrm/tests/includes/SquareFileProbe.php +++ b/sites/all/modules/offline2civicrm/tests/includes/SquareFileProbe.php @@ -1,7 +1,8 @@ <?php class SquareFileProbe extends SquareFile { - function _parseRow( $data ) { - return $this->parseRow( $data ); - } + + function _parseRow($data) { + return $this->parseRow($data); + } } -- To view, visit https://gerrit.wikimedia.org/r/392553 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic13a06b65f85fb007c9938dccf838cf59eb2ea61 Gerrit-PatchSet: 3 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org> Gerrit-Reviewer: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits