Code Duplication    Length = 28-28 lines in 2 locations

tests/phpunit/tests/rest-api/rest-comments-controller.php 2 locations

@@ 653-680 (lines=28) @@
650
        $this->assertErrorResponse('rest_forbidden_param', $response, 401);
651
    }
652
653
    public function test_get_items_parent_arg() 
654
    {
655
        $args = array(
656
         'comment_approved'  => 1,
657
         'comment_post_ID'   => self::$post_id,
658
        );
659
        $parent_id = $this->factory->comment->create($args);
660
        $parent_id2 = $this->factory->comment->create($args);
661
        $args['comment_parent'] = $parent_id;
662
        $this->factory->comment->create($args);
663
        $args['comment_parent'] = $parent_id2;
664
        $this->factory->comment->create($args);
665
        // All comments in the database
666
        $request = new WP_REST_Request('GET', '/wp/v2/comments');
667
        $response = $this->server->dispatch($request);
668
        $this->assertCount(5, $response->get_data());
669
        // Limit to the parent
670
        $request->set_param('parent', $parent_id);
671
        $response = $this->server->dispatch($request);
672
        $this->assertCount(1, $response->get_data());
673
        // Limit to two parents
674
        $request->set_param('parent', array( $parent_id, $parent_id2 ));
675
        $response = $this->server->dispatch($request);
676
        $this->assertCount(2, $response->get_data());
677
        // Invalid parent should error
678
        $request->set_param('parent', 'invalid');
679
        $response = $this->server->dispatch($request);
680
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
681
    }
682
683
    public function test_get_items_parent_exclude_arg() 
@@ 683-710 (lines=28) @@
680
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
681
    }
682
683
    public function test_get_items_parent_exclude_arg() 
684
    {
685
        $args = array(
686
         'comment_approved'  => 1,
687
         'comment_post_ID'   => self::$post_id,
688
        );
689
        $parent_id = $this->factory->comment->create($args);
690
        $parent_id2 = $this->factory->comment->create($args);
691
        $args['comment_parent'] = $parent_id;
692
        $this->factory->comment->create($args);
693
        $args['comment_parent'] = $parent_id2;
694
        $this->factory->comment->create($args);
695
        // All comments in the database
696
        $request = new WP_REST_Request('GET', '/wp/v2/comments');
697
        $response = $this->server->dispatch($request);
698
        $this->assertCount(5, $response->get_data());
699
        // Exclude this particular parent
700
        $request->set_param('parent_exclude', $parent_id);
701
        $response = $this->server->dispatch($request);
702
        $this->assertCount(4, $response->get_data());
703
        // Exclude both comment parents
704
        $request->set_param('parent_exclude', array( $parent_id, $parent_id2 ));
705
        $response = $this->server->dispatch($request);
706
        $this->assertCount(3, $response->get_data());
707
        // Invalid parent id should error
708
        $request->set_param('parent_exclude', 'invalid');
709
        $response = $this->server->dispatch($request);
710
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
711
    }
712
713
    public function test_get_items_search_query()