Skip to content

Commit 5012f8e

Browse files
author
Timur Karimov
committed
isolate tested gateway within its test to avoid dependencies that lead to test regressions
1 parent 678059d commit 5012f8e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/unit/test-class-wc-payment-gateway-wcpay.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ public function set_up() {
236236
->getMock();
237237

238238
$this->init_gateways();
239+
240+
// Replace the main class's gateway for testing purposes.
241+
$this->_gateway = WC_Payments::get_gateway();
239242
WC_Payments::set_gateway( $this->card_gateway );
240243

241244
$this->woopay_utilities = new WooPay_Utilities();
@@ -266,6 +269,9 @@ public function tear_down() {
266269
// Restore the cache service in the main class.
267270
WC_Payments::set_database_cache( $this->_cache );
268271

272+
// Restore the gateway in the main class.
273+
WC_Payments::set_gateway( $this->_gateway );
274+
269275
// Fall back to an US store.
270276
update_option( 'woocommerce_store_postcode', '94110' );
271277
$this->card_gateway->update_option( 'saved_cards', 'yes' );

0 commit comments

Comments
 (0)