@@ 30-44 (lines=15) @@ | ||
27 | ||
28 | } |
|
29 | ||
30 | public function test_context_param() { |
|
31 | // Collection |
|
32 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' ); |
|
33 | $response = $this->server->dispatch( $request ); |
|
34 | $data = $response->get_data(); |
|
35 | $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); |
|
36 | $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); |
|
37 | // Single |
|
38 | $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); |
|
39 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages/' . $page_id ); |
|
40 | $response = $this->server->dispatch( $request ); |
|
41 | $data = $response->get_data(); |
|
42 | $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); |
|
43 | $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); |
|
44 | } |
|
45 | ||
46 | public function test_registered_query_params() { |
|
47 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' ); |
@@ 27-41 (lines=15) @@ | ||
24 | $this->assertArrayHasKey( '/wp/v2/categories/(?P<id>[\d]+)', $routes ); |
|
25 | } |
|
26 | ||
27 | public function test_context_param() { |
|
28 | // Collection |
|
29 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories' ); |
|
30 | $response = $this->server->dispatch( $request ); |
|
31 | $data = $response->get_data(); |
|
32 | $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); |
|
33 | $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); |
|
34 | // Single |
|
35 | $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) ); |
|
36 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories/' . $category1 ); |
|
37 | $response = $this->server->dispatch( $request ); |
|
38 | $data = $response->get_data(); |
|
39 | $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); |
|
40 | $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); |
|
41 | } |
|
42 | ||
43 | public function test_registered_query_params() { |
|
44 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories' ); |
@@ 27-41 (lines=15) @@ | ||
24 | $this->assertArrayHasKey( '/wp/v2/tags/(?P<id>[\d]+)', $routes ); |
|
25 | } |
|
26 | ||
27 | public function test_context_param() { |
|
28 | // Collection |
|
29 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' ); |
|
30 | $response = $this->server->dispatch( $request ); |
|
31 | $data = $response->get_data(); |
|
32 | $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); |
|
33 | $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); |
|
34 | // Single |
|
35 | $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) ); |
|
36 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags/' . $tag1 ); |
|
37 | $response = $this->server->dispatch( $request ); |
|
38 | $data = $response->get_data(); |
|
39 | $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); |
|
40 | $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); |
|
41 | } |
|
42 | ||
43 | public function test_registered_query_params() { |
|
44 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' ); |