Code Duplication    Length = 18-19 lines in 2 locations

tests/phpunit/tests/rest-api/rest-tags-controller.php 1 location

@@ 162-179 (lines=18) @@
159
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
160
    }
161
162
    public function test_get_items_exclude_query() 
163
    {
164
        $id1 = $this->factory->tag->create();
165
        $id2 = $this->factory->tag->create();
166
        $request = new WP_REST_Request('GET', '/wp/v2/tags');
167
        $response = $this->server->dispatch($request);
168
        $data = $response->get_data();
169
        $this->assertTrue(in_array($id1, wp_list_pluck($data, 'id'), true));
170
        $this->assertTrue(in_array($id2, wp_list_pluck($data, 'id'), true));
171
        $request->set_param('exclude', array( $id2 ));
172
        $response = $this->server->dispatch($request);
173
        $data = $response->get_data();
174
        $this->assertTrue(in_array($id1, wp_list_pluck($data, 'id'), true));
175
        $this->assertFalse(in_array($id2, wp_list_pluck($data, 'id'), true));
176
        // Invalid exclude value should fail
177
        $request->set_param('exclude', array( 'invalid' ));
178
        $response = $this->server->dispatch($request);
179
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
180
    }
181
182
    public function test_get_items_offset_query() 

tests/phpunit/tests/rest-api/rest-users-controller.php 1 location

@@ 496-514 (lines=19) @@
493
494
    }
495
496
    public function test_get_items_exclude_query() 
497
    {
498
        wp_set_current_user(self::$user);
499
        $id1 = $this->factory->user->create();
500
        $id2 = $this->factory->user->create();
501
        $request = new WP_REST_Request('GET', '/wp/v2/users');
502
        $response = $this->server->dispatch($request);
503
        $data = $response->get_data();
504
        $this->assertTrue(in_array($id1, wp_list_pluck($data, 'id'), true));
505
        $this->assertTrue(in_array($id2, wp_list_pluck($data, 'id'), true));
506
        $request->set_param('exclude', array( $id2 ));
507
        $response = $this->server->dispatch($request);
508
        $data = $response->get_data();
509
        $this->assertTrue(in_array($id1, wp_list_pluck($data, 'id'), true));
510
        $this->assertFalse(in_array($id2, wp_list_pluck($data, 'id'), true));
511
        // Invalid exlude value should error.
512
        $request->set_param('exclude', 'none-of-those-please');
513
        $response = $this->server->dispatch($request);
514
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
515
    }
516
517
    public function test_get_items_search()