Code Duplication    Length = 14-15 lines in 3 locations

tests/test-rest-tags-controller.php 1 location

@@ 113-126 (lines=14) @@
110
		$this->assertEquals( $id3, $data[0]['id'] );
111
	}
112
113
	public function test_get_items_exclude_query() {
114
		$id1 = $this->factory->tag->create();
115
		$id2 = $this->factory->tag->create();
116
		$request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
117
		$response = $this->server->dispatch( $request );
118
		$data = $response->get_data();
119
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
120
		$this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
121
		$request->set_param( 'exclude', array( $id2 ) );
122
		$response = $this->server->dispatch( $request );
123
		$data = $response->get_data();
124
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
125
		$this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
126
	}
127
128
	public function test_get_items_offset_query() {
129
		$id1 = $this->factory->tag->create();

tests/test-rest-categories-controller.php 1 location

@@ 195-208 (lines=14) @@
192
		$this->assertEquals( $id3, $data[0]['id'] );
193
	}
194
195
	public function test_get_items_exclude_query() {
196
		$id1 = $this->factory->category->create();
197
		$id2 = $this->factory->category->create();
198
		$request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
199
		$response = $this->server->dispatch( $request );
200
		$data = $response->get_data();
201
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
202
		$this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
203
		$request->set_param( 'exclude', array( $id2 ) );
204
		$response = $this->server->dispatch( $request );
205
		$data = $response->get_data();
206
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
207
		$this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
208
	}
209
210
	public function test_get_items_orderby_args() {
211
		$this->factory->category->create( array( 'name' => 'Apple' ) );

tests/test-rest-users-controller.php 1 location

@@ 306-320 (lines=15) @@
303
304
	}
305
306
	public function test_get_items_exclude_query() {
307
		wp_set_current_user( $this->user );
308
		$id1 = $this->factory->user->create();
309
		$id2 = $this->factory->user->create();
310
		$request = new WP_REST_Request( 'GET', '/wp/v2/users' );
311
		$response = $this->server->dispatch( $request );
312
		$data = $response->get_data();
313
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
314
		$this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
315
		$request->set_param( 'exclude', array( $id2 ) );
316
		$response = $this->server->dispatch( $request );
317
		$data = $response->get_data();
318
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
319
		$this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
320
	}
321
322
	public function test_get_items_search() {
323
		wp_set_current_user( $this->user );