2016-07-25 18:19:44 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WC REST API Unit Test Case (for WP-API Endpoints).
|
|
|
|
*
|
|
|
|
* Provides REST API specific methods and setup/teardown.
|
|
|
|
*
|
2017-03-15 16:36:53 +00:00
|
|
|
* @since 3.0
|
2016-07-25 18:19:44 +00:00
|
|
|
*/
|
|
|
|
|
2018-06-13 15:55:39 +00:00
|
|
|
class WC_REST_Unit_Test_Case extends WC_Unit_Test_Case {
|
2016-07-25 18:19:44 +00:00
|
|
|
|
2018-06-13 15:55:39 +00:00
|
|
|
protected $server;
|
2016-07-25 18:19:44 +00:00
|
|
|
|
2018-06-13 15:55:39 +00:00
|
|
|
/**
|
|
|
|
* Setup our test server.
|
|
|
|
*/
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
global $wp_rest_server;
|
|
|
|
$wp_rest_server = new WP_Test_Spy_REST_Server();
|
|
|
|
$this->server = $wp_rest_server;
|
|
|
|
do_action( 'rest_api_init' );
|
2018-08-27 19:05:13 +00:00
|
|
|
|
|
|
|
// Reset payment gateways.
|
2019-05-01 22:05:00 +00:00
|
|
|
$gateways = WC_Payment_Gateways::instance();
|
2018-08-27 19:05:13 +00:00
|
|
|
$gateways->payment_gateways = array();
|
|
|
|
$gateways->init();
|
2018-06-13 15:55:39 +00:00
|
|
|
}
|
2016-07-25 18:19:44 +00:00
|
|
|
|
2018-06-13 15:55:39 +00:00
|
|
|
/**
|
|
|
|
* Unset the server.
|
|
|
|
*/
|
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
2018-06-01 12:49:02 +00:00
|
|
|
global $wp_rest_server;
|
|
|
|
unset( $this->server );
|
2018-06-13 15:55:39 +00:00
|
|
|
$wp_rest_server = null;
|
|
|
|
}
|
2016-07-25 18:19:44 +00:00
|
|
|
}
|