Code Duplication    Length = 11-16 lines in 4 locations

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

@@ 186-197 (lines=12) @@
183
        $this->assertEquals(count($categories), count($data));
184
    }
185
186
    public function test_get_items_by_parent_non_found() 
187
    {
188
        $parent1 = $this->factory->category->create(array( 'name' => 'Homer' ));
189
190
        $request = new WP_REST_Request('GET', '/wp/v2/categories');
191
        $request->set_param('parent', $parent1);
192
        $response = $this->server->dispatch($request);
193
194
        $this->assertEquals(200, $response->get_status());
195
        $data = $response->get_data();
196
197
        $this->assertEquals(array(), $data);
198
    }
199
200
    public function test_get_items_invalid_page() 

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

@@ 424-438 (lines=15) @@
421
        $this->assertEquals(200, $response->get_status());
422
    }
423
424
    public function test_get_items_for_post() 
425
    {
426
        $second_post_id = $this->factory->post->create();
427
        $this->factory->comment->create_post_comments($second_post_id, 2);
428
429
        $request = new WP_REST_Request('GET', '/wp/v2/comments');
430
        $request->set_query_params(
431
            array(
432
            'post' => $second_post_id,
433
            ) 
434
        );
435
436
        $response = $this->server->dispatch($request);
437
        $this->assertEquals(200, $response->get_status());
438
439
        $comments = $response->get_data();
440
        $this->assertCount(2, $comments);
441
    }

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

@@ 436-451 (lines=16) @@
433
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
434
    }
435
436
    public function test_get_items_status_without_permissions() 
437
    {
438
        $draft_id = $this->factory->post->create(
439
            array(
440
            'post_status' => 'draft',
441
            ) 
442
        );
443
        wp_set_current_user(0);
444
445
        $request = new WP_REST_Request('GET', '/wp/v2/posts');
446
        $response = $this->server->dispatch($request);
447
448
        $this->assertEquals(200, $response->get_status());
449
450
        $all_data = $response->get_data();
451
        foreach ( $all_data as $post ) {
452
            $this->assertNotEquals($draft_id, $post['id']);
453
        }
454
    }

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

@@ 341-351 (lines=11) @@
338
        }
339
    }
340
341
    public function test_get_items_post_empty() 
342
    {
343
        $post_id = $this->factory->post->create();
344
345
        $request = new WP_REST_Request('GET', '/wp/v2/tags');
346
        $request->set_param('post', $post_id);
347
        $response = $this->server->dispatch($request);
348
        $this->assertEquals(200, $response->get_status());
349
350
        $data = $response->get_data();
351
        $this->assertCount(0, $data);
352
    }
353
354
    public function test_get_items_custom_tax_post_args()