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