From 3492f397d46785386f011d88423708d1ce4e4f67 Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Tue, 14 Jun 2016 16:57:35 -0600 Subject: [PATCH] Add test coverage for shipping zone schema endpoint. --- tests/unit-tests/api/shipping-zones.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit-tests/api/shipping-zones.php b/tests/unit-tests/api/shipping-zones.php index 4f0432c9855..b44795b9e3c 100644 --- a/tests/unit-tests/api/shipping-zones.php +++ b/tests/unit-tests/api/shipping-zones.php @@ -136,4 +136,22 @@ class WC_Tests_API_Shipping_Zones extends WC_Unit_Test_Case { remove_filter( 'wc_shipping_enabled', '__return_false' ); } + + /** + * Test Shipping Zone schema. + * @since 2.7.0 + */ + public function test_get_shipping_zone_schema() { + $request = new WP_REST_Request( 'OPTIONS', '/wc/v1/shipping/zones' ); + $response = $this->server->dispatch( $request ); + $data = $response->get_data(); + $properties = $data['schema']['properties']; + $this->assertEquals( 3, count( $properties ) ); + $this->assertArrayHasKey( 'id', $properties ); + $this->assertTrue( $properties['id']['readonly'] ); + $this->assertArrayHasKey( 'name', $properties ); + $this->assertTrue( $properties['name']['required'] ); + $this->assertArrayHasKey( 'order', $properties ); + $this->assertFalse( $properties['order']['required'] ); + } } \ No newline at end of file