File tree Expand file tree Collapse file tree 2 files changed +34
-12
lines changed
Expand file tree Collapse file tree 2 files changed +34
-12
lines changed Original file line number Diff line number Diff line change 55use Codeception \TestCase \WPAjaxTestCase ;
66
77class WCAjaxTestCase extends WPAjaxTestCase {
8+ private $ original_acf_stores ;
9+
810 /**
911 * @return WC_UnitTest_Factory
1012 */
@@ -15,4 +17,24 @@ protected static function factory() {
1517 }
1618 return $ factory ;
1719 }
20+
21+ public function _setUp ()
22+ {
23+ parent ::_setUp ();
24+ global $ acf_stores ;
25+ $ this ->original_acf_stores = serialize ( $ acf_stores );
26+ WC ()->shipping ()->unregister_shipping_methods ();
27+ WC ()->shipping ()->reset_shipping ();
28+ WC ()->cart = null ;
29+ WC ()->session = null ;
30+ WC ()->customer = null ;
31+ wc_load_cart ();
32+ }
33+
34+ public function _tearDown ()
35+ {
36+ parent ::_tearDown ();
37+ global $ acf_stores ;
38+ $ acf_stores = unserialize ($ this ->original_acf_stores );
39+ }
1840}
Original file line number Diff line number Diff line change 55use Codeception \TestCase \WPTestCase ;
66
77class WCTestCase extends WPTestCase {
8- private $ original_cart ;
9- private $ original_session ;
10- private $ original_customer ;
11- private $ original_query ;
8+ private $ original_acf_stores ;
129
1310 /**
1411 * @return WC_UnitTest_Factory
@@ -24,18 +21,21 @@ protected static function factory() {
2421 public function _setUp ()
2522 {
2623 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 ;
24+ global $ acf_stores ;
25+ $ this ->original_acf_stores = serialize ( $ acf_stores );
26+ WC ()->shipping ()->unregister_shipping_methods ();
27+ WC ()->shipping ()->reset_shipping ();
28+ WC ()->cart = null ;
29+ WC ()->session = null ;
30+ WC ()->customer = null ;
31+ wc_load_cart ();
3132 }
3233
3334 public function _tearDown ()
3435 {
3536 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 ;
37+ wc_clear_notices ();
38+ global $ acf_stores ;
39+ $ acf_stores = unserialize ($ this ->original_acf_stores );
4040 }
4141}
You can’t perform that action at this time.
0 commit comments