Skip to content

Commit fd236bd

Browse files
authored
Merge pull request #12 from level-level/restore-wc-property-instances-after-test
Restore instances after test runs
2 parents 89488fb + 37c7efe commit fd236bd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/WCTestCase.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
use Codeception\TestCase\WPTestCase;
66

77
class WCTestCase extends WPTestCase {
8+
private $original_cart;
9+
private $original_session;
10+
private $original_customer;
11+
private $original_query;
12+
813
/**
914
* @return WC_UnitTest_Factory
1015
*/
@@ -15,4 +20,22 @@ protected static function factory() {
1520
}
1621
return $factory;
1722
}
23+
24+
public function _setUp()
25+
{
26+
parent::_setUp();
27+
$this->original_cart = WC()->cart;
28+
$this->original_session = WC()->session;
29+
$this->original_customer = WC()->customer;
30+
$this->original_query = WC()->query;
31+
}
32+
33+
public function _tearDown()
34+
{
35+
parent::_tearDown();
36+
WC()->cart = $this->original_cart;
37+
WC()->session = $this->original_session;
38+
WC()->customer = $this->original_customer;
39+
WC()->query = $this->original_query;
40+
}
1841
}

0 commit comments

Comments
 (0)