@@ 94-111 (lines=18) @@ | ||
91 | $this->assertEquals( 'The Be Sharps', $data[1]['name'] ); |
|
92 | } |
|
93 | ||
94 | public function test_get_items_include_query() { |
|
95 | $id1 = $this->factory->tag->create(); |
|
96 | $id2 = $this->factory->tag->create(); |
|
97 | $id3 = $this->factory->tag->create(); |
|
98 | $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); |
|
99 | // Orderby=>asc |
|
100 | $request->set_param( 'include', array( $id3, $id1 ) ); |
|
101 | $response = $this->server->dispatch( $request ); |
|
102 | $data = $response->get_data(); |
|
103 | $this->assertEquals( 2, count( $data ) ); |
|
104 | $this->assertEquals( $id1, $data[0]['id'] ); |
|
105 | // Orderby=>include |
|
106 | $request->set_param( 'orderby', 'include' ); |
|
107 | $response = $this->server->dispatch( $request ); |
|
108 | $data = $response->get_data(); |
|
109 | $this->assertEquals( 2, count( $data ) ); |
|
110 | $this->assertEquals( $id3, $data[0]['id'] ); |
|
111 | } |
|
112 | ||
113 | public function test_get_items_exclude_query() { |
|
114 | $id1 = $this->factory->tag->create(); |
@@ 176-193 (lines=18) @@ | ||
173 | $this->assertContains( 'page must be greater than 1 (inclusive)', $first_error ); |
|
174 | } |
|
175 | ||
176 | public function test_get_items_include_query() { |
|
177 | $id1 = $this->factory->category->create(); |
|
178 | $this->factory->category->create(); |
|
179 | $id3 = $this->factory->category->create(); |
|
180 | $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); |
|
181 | // Orderby=>asc |
|
182 | $request->set_param( 'include', array( $id3, $id1 ) ); |
|
183 | $response = $this->server->dispatch( $request ); |
|
184 | $data = $response->get_data(); |
|
185 | $this->assertEquals( 2, count( $data ) ); |
|
186 | $this->assertEquals( $id1, $data[0]['id'] ); |
|
187 | // Orderby=>include |
|
188 | $request->set_param( 'orderby', 'include' ); |
|
189 | $response = $this->server->dispatch( $request ); |
|
190 | $data = $response->get_data(); |
|
191 | $this->assertEquals( 2, count( $data ) ); |
|
192 | $this->assertEquals( $id3, $data[0]['id'] ); |
|
193 | } |
|
194 | ||
195 | public function test_get_items_exclude_query() { |
|
196 | $id1 = $this->factory->category->create(); |