woocommerce/tests/framework/class-wc-rest-unit-test-cas...

40 lines
783 B
PHP
Raw Normal View History

<?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
*/
2018-06-13 15:55:39 +00:00
class WC_REST_Unit_Test_Case extends WC_Unit_Test_Case {
2018-06-13 15:55:39 +00:00
protected $server;
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.
$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
}
2018-06-13 15:55:39 +00:00
/**
* Unset the server.
*/
public function tearDown() {
parent::tearDown();
global $wp_rest_server;
unset( $this->server );
2018-06-13 15:55:39 +00:00
$wp_rest_server = null;
}
}