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

@@ 399-413 (lines=15) @@
396
397
	}
398
399
	public function test_get_items_exclude_query() {
400
		wp_set_current_user( $this->user );
401
		$id1 = $this->factory->user->create();
402
		$id2 = $this->factory->user->create();
403
		$request = new WP_REST_Request( 'GET', '/wp/v2/users' );
404
		$response = $this->server->dispatch( $request );
405
		$data = $response->get_data();
406
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
407
		$this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
408
		$request->set_param( 'exclude', array( $id2 ) );
409
		$response = $this->server->dispatch( $request );
410
		$data = $response->get_data();
411
		$this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ) ) );
412
		$this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ) ) );
413
	}
414
415
	public function test_get_items_search() {
416
		wp_set_current_user( $this->user );