Skip to content
Snippets Groups Projects
Commit 9936ccfa authored by mattwire's avatar mattwire
Browse files

Test fixes

parent 4b980053
No related branches found
No related tags found
1 merge request!176Release 6.7
...@@ -54,17 +54,26 @@ abstract class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implement ...@@ -54,17 +54,26 @@ abstract class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implement
]; ];
public function setUpHeadless() { public function setUpHeadless() {
} // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
// See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
public function setUp(): void { static $reInstallOnce = TRUE;
parent::setUp();
// we only need to do the shared library once $reInstall = FALSE;
if (!isset($reInstallOnce)) {
$reInstallOnce=TRUE;
$reInstall = TRUE;
}
if (!is_dir(__DIR__ . '/../../../../../mjwshared')) { if (!is_dir(__DIR__ . '/../../../../../mjwshared')) {
civicrm_api3('Extension', 'download', ['key' => 'mjwshared']); civicrm_api3('Extension', 'download', ['key' => 'mjwshared']);
} }
else {
civicrm_api3('Extension', 'install', ['keys' => 'mjwshared']); return \Civi\Test::headless()
} ->installMe(__DIR__)
->install('mjwshared')
->apply($reInstall);
}
public function setUp(): void {
civicrm_api3('Extension', 'install', ['keys' => 'com.drastikbydesign.stripe']); civicrm_api3('Extension', 'install', ['keys' => 'com.drastikbydesign.stripe']);
require_once('vendor/stripe/stripe-php/init.php'); require_once('vendor/stripe/stripe-php/init.php');
$this->createPaymentProcessor(); $this->createPaymentProcessor();
...@@ -72,13 +81,6 @@ abstract class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implement ...@@ -72,13 +81,6 @@ abstract class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implement
$this->created_ts = time(); $this->created_ts = time();
} }
public function tearDown(): void {
civicrm_api3('PaymentProcessor', 'delete', ['id' => $this->paymentProcessorID]);
civicrm_api3('Extension', 'disable', ['keys' => 'com.drastikbydesign.stripe']);
civicrm_api3('Extension', 'uninstall', ['keys' => 'com.drastikbydesign.stripe']);
parent::tearDown();
}
/** /**
* *
*/ */
...@@ -515,7 +517,7 @@ class PropertySpy implements ArrayAccess, Iterator, Countable, JsonSerializable ...@@ -515,7 +517,7 @@ class PropertySpy implements ArrayAccess, Iterator, Countable, JsonSerializable
/** /**
* Stubs a method by returning a value from a map. * Stubs a method by returning a value from a map.
*/ */
class ValueMapOrDie implements \PHPUnit\Framework\MockObject\Stub { class ValueMapOrDie implements \PHPUnit\Framework\MockObject\Stub\Stub {
use \PHPUnit\Framework\MockObject\Api; use \PHPUnit\Framework\MockObject\Api;
......
...@@ -50,7 +50,6 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest { ...@@ -50,7 +50,6 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
* update it after creation. @todo The membership should also be updated. * update it after creation. @todo The membership should also be updated.
*/ */
public function testNewRecurringInvoicePaymentSucceeded() { public function testNewRecurringInvoicePaymentSucceeded() {
$this->mockRecurringPaymentSetup(); $this->mockRecurringPaymentSetup();
$this->simulateEvent([ $this->simulateEvent([
'type' => 'invoice.payment_succeeded', 'type' => 'invoice.payment_succeeded',
...@@ -940,7 +939,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest { ...@@ -940,7 +939,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
]); ]);
// //
// Check the CotnributionRecur // Check the ContributionRecur
// //
// The subscription ID should be in both processor_id and trxn_id fields // The subscription ID should be in both processor_id and trxn_id fields
// We expect it to be pending // We expect it to be pending
...@@ -954,7 +953,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest { ...@@ -954,7 +953,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
/** /**
* *
*/ */
protected function returnValueMapOrDie($map) :ValueMapOrDie { protected function returnValueMapOrDie($map): ValueMapOrDie {
return new ValueMapOrDie($map); return new ValueMapOrDie($map);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment