Eileen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/329356 )
Change subject: Consolidate test cleanup routine into parent class
......................................................................
Consolidate test cleanup routine into parent class
Change-Id: I2e29ba761dbf00f3893de9f82276a6c0c4aba034
---
M sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php
M sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php
2 files changed, 30 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/56/329356/1
diff --git a/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php
b/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php
index e677c9e..c949e77 100644
--- a/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php
+++ b/sites/all/modules/offline2civicrm/tests/JpMorganFileTest.php
@@ -16,6 +16,7 @@
$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 testParseRow() {
@@ -58,20 +59,9 @@
function testImport() {
//FIXME
$_GET['q'] = '';
- //FIXME
civicrm_initialize();
-
- // Clean slate.
- $contributions = wmf_civicrm_get_contributions_from_gateway_id(
'jpmorgan', '1234TEST' );
- if ( $contributions ) {
- foreach ( $contributions as $existing ) {
- $success = civicrm_api_classapi()->Contribution->Delete( array(
- 'id' => $existing['id'],
- 'version' => 3,
- ) );
- $this->assertTrue( $success );
- }
- }
+ $this->trxn_id = '1234TEST';
+ $this->doCleanUp();
$this->setExchangeRates( wmf_common_date_parse_string( '2000-04-01' ),
array( 'USD' => 1, 'EUR' => 3 ) );
diff --git
a/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php
b/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php
index ee09c73..6132b09 100644
--- a/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php
+++ b/sites/all/modules/offline2civicrm/tests/includes/BaseChecksFileTest.php
@@ -1,6 +1,21 @@
<?php
class BaseChecksFileTest extends BaseWmfDrupalPhpUnitTestCase {
+ /**
+ * Gateway.
+ *
+ * eg. jpmorgan, paypal etc.
+ *
+ * @var string
+ */
+ protected $gateway;
+
+ /**
+ * Transaction id being worked with. This is combined with the gateway for
the civi trxn_id.
+ *
+ * @var string
+ */
+ protected $trxn_id;
/**
* Test and remove some dynamic fields, to simplify test fixtures.
*/
@@ -20,4 +35,16 @@
unset( $msg['source_version'] );
unset( $msg['source_enqueued_time'] );
}
+
+ /**
+ * Clean up transactions from previous test runs.
+ */
+ function doCleanUp() {
+ $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']));
+ }
+ }
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/329356
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e29ba761dbf00f3893de9f82276a6c0c4aba034
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits