Skip to content

Commit

Permalink
isolate tested gateway within its test to avoid dependencies that lea…
Browse files Browse the repository at this point in the history
…d to test regressions
  • Loading branch information
Timur Karimov committed Jan 3, 2024
1 parent 678059d commit 5012f8e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/unit/test-class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ public function set_up() {
->getMock();

$this->init_gateways();

// Replace the main class's gateway for testing purposes.
$this->_gateway = WC_Payments::get_gateway();
WC_Payments::set_gateway( $this->card_gateway );

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

// Restore the gateway in the main class.
WC_Payments::set_gateway( $this->_gateway );

// Fall back to an US store.
update_option( 'woocommerce_store_postcode', '94110' );
$this->card_gateway->update_option( 'saved_cards', 'yes' );
Expand Down

0 comments on commit 5012f8e

Please sign in to comment.