Eileen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/329646 )

Change subject: Fix test that was not running to run.
......................................................................

Fix test that was not running to run.

The naming convention on this test file meant it was not running. I got it to 
run,
although I hit some global wierdness & TBH I don't know what it actually tests 
:-)

Change-Id: Id86702c04a5d3d62271b303cb9b66e6d6a9fd714
---
R sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php
1 file changed, 18 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/46/329646/1

diff --git 
a/sites/all/modules/offline2civicrm/tests/ContributionConversion.test 
b/sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php
similarity index 61%
rename from sites/all/modules/offline2civicrm/tests/ContributionConversion.test
rename to sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php
index 4b4a8fb..da00108 100644
--- a/sites/all/modules/offline2civicrm/tests/ContributionConversion.test
+++ b/sites/all/modules/offline2civicrm/tests/ContributionConversionTest.php
@@ -1,60 +1,45 @@
 <?php
 
-module_load_include( 'php', 'queue2civicrm', 'tests/simpletest/BaseTestCase' );
-
-class ContributionConversionTest extends BaseTestCase {
-    public static function getInfo() {
-        return array(
-            'name' => 'ContributionConversion',
-            'group' => 'Wikimedia',
-            'description' => 'Convert single contributions to recurring',
-        );
-    }
+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);
 
-        $api = civicrm_api_classapi();
-        $api->Contact->Create( array(
+        $result = $this->callAPISuccess('Contact', 'create', array(
             'contact_type' => 'Individual',
             'email' => 'f...@example.com',
-            'version' => 3,
-        ) );
-        $this->contact_id = $api->id;
+        ));
+        $this->contact_id = $result['id'];
 
         $this->gateway_txn_id = "NaN-" . mt_rand();
         $this->transaction = WmfTransaction::from_unique_id( "GLOBALCOLLECT 
{$this->gateway_txn_id}" );
 
-        $api->Contribution->Create( array(
+        $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() ),
-            'version' => 3,
-        ) );
-        $this->contribution_id = $api->id;
+        ));
+        $this->contribution_id = $contributionResult['id'];
 
-        wmf_civicrm_set_custom_field_values( $this->contribution_id, array(
+        wmf_civicrm_set_custom_field_values($this->contribution_id, array(
             'original_amount' => '20.01',
             'original_currency' => 'USD',
-        ) );
+        ));
     }
 
     public function tearDown() {
-        $api = civicrm_api_classapi();
-
-        $api->Contribution->Delete( array(
-            'id' => $this->contribution_id,
-            'version' => 3,
-        ) );
-
-        $api->Contact->Delete( array(
-            'id' => $this->contact_id,
-            'version' => 3,
-        ) );
-
         parent::tearDown();
+        $this->callAPISuccess('Contribution', 'delete', array('id' => 
$this->contribution_id));
+        $this->callAPISuccess('Contact', 'delete', array('id' => 
$this->contact_id));
     }
 
     public function testMakeRecurring() {

-- 
To view, visit https://gerrit.wikimedia.org/r/329646
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id86702c04a5d3d62271b303cb9b66e6d6a9fd714
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to