From 2a7e81a80934b3fa53efda939e1468ea808ded2d Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Tue, 14 Jun 2016 16:36:25 -0600 Subject: [PATCH] Initial Shipping Zones unit test coverage, testing route registration. --- tests/unit-tests/api/shipping-zones.php | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/unit-tests/api/shipping-zones.php diff --git a/tests/unit-tests/api/shipping-zones.php b/tests/unit-tests/api/shipping-zones.php new file mode 100644 index 00000000000..e9e328083f8 --- /dev/null +++ b/tests/unit-tests/api/shipping-zones.php @@ -0,0 +1,54 @@ +server = $wp_rest_server = new WP_Test_Spy_REST_Server; + do_action( 'rest_api_init' ); + $this->endpoint = new WC_REST_Shipping_Zones_Controller(); + $this->user = $this->factory->user->create( array( + 'role' => 'administrator', + ) ); + $this->zones = array(); + } + + /** + * Unset the server. + */ + public function tearDown() { + parent::tearDown(); + global $wp_rest_server; + $wp_rest_server = null; + foreach( $this->zones as $zone ) { + $zone->delete(); + } + } + + /** + * Test route registration. + * @since 2.7.0 + */ + public function test_register_routes() { + $routes = $this->server->get_routes(); + $this->assertArrayHasKey( '/wc/v1/shipping/zones', $routes ); + $this->assertArrayHasKey( '/wc/v1/shipping/zones/(?P[\d-]+)', $routes ); + } +} \ No newline at end of file