Code Duplication    Length = 17-18 lines in 5 locations

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

@@ 1624-1641 (lines=18) @@
1621
        $this->assertEquals('127.0.0.2', $new_comment->comment_author_IP);
1622
    }
1623
1624
    public function test_create_comment_no_post_id() 
1625
    {
1626
        wp_set_current_user(self::$admin_id);
1627
1628
        $params = array(
1629
         'author_name'  => 'Comic Book Guy',
1630
         'author_email' => '[email protected]',
1631
         'author_url'   => 'http://androidsdungeon.com',
1632
         'content'      => 'Worst Comment Ever!',
1633
         'status'       => 'approved',
1634
        );
1635
        $request = new WP_REST_Request('POST', '/wp/v2/comments');
1636
        $request->add_header('content-type', 'application/json');
1637
        $request->set_body(wp_json_encode($params));
1638
1639
        $response = $this->server->dispatch($request);
1640
1641
        $this->assertErrorResponse('rest_comment_invalid_post_id', $response, 403);
1642
    }
1643
1644
    public function test_create_comment_no_post_id_no_permission() 

tests/phpunit/tests/rest-api/rest-users-controller.php 4 locations

@@ 1080-1097 (lines=18) @@
1077
        $this->assertErrorResponse('rest_cannot_create_user', $response, 403);
1078
    }
1079
1080
    public function test_create_user_invalid_id() 
1081
    {
1082
        $this->allow_user_to_manage_multisite();
1083
        wp_set_current_user(self::$user);
1084
1085
        $params = array(
1086
         'id'       => '156',
1087
         'username' => 'lisasimpson',
1088
         'password' => 'DavidHasselhoff',
1089
         'email'    => '[email protected]',
1090
        );
1091
1092
        $request = new WP_REST_Request('POST', '/wp/v2/users');
1093
        $request->add_header('content-type', 'application/x-www-form-urlencoded');
1094
        $request->set_body_params($params);
1095
        $response = $this->server->dispatch($request);
1096
1097
        $this->assertErrorResponse('rest_user_exists', $response, 400);
1098
    }
1099
1100
    public function test_create_user_invalid_email() 
@@ 1100-1116 (lines=17) @@
1097
        $this->assertErrorResponse('rest_user_exists', $response, 400);
1098
    }
1099
1100
    public function test_create_user_invalid_email() 
1101
    {
1102
        $this->allow_user_to_manage_multisite();
1103
        wp_set_current_user(self::$user);
1104
1105
        $params = array(
1106
         'username' => 'lisasimpson',
1107
         'password' => 'DavidHasselhoff',
1108
         'email'    => 'something',
1109
        );
1110
1111
        $request = new WP_REST_Request('POST', '/wp/v2/users');
1112
        $request->add_header('content-type', 'application/x-www-form-urlencoded');
1113
        $request->set_body_params($params);
1114
        $response = $this->server->dispatch($request);
1115
1116
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
1117
    }
1118
1119
    public function test_create_user_invalid_role() 
@@ 1119-1136 (lines=18) @@
1116
        $this->assertErrorResponse('rest_invalid_param', $response, 400);
1117
    }
1118
1119
    public function test_create_user_invalid_role() 
1120
    {
1121
        $this->allow_user_to_manage_multisite();
1122
        wp_set_current_user(self::$user);
1123
1124
        $params = array(
1125
         'username' => 'maggiesimpson',
1126
         'password' => 'i_shot_mrburns',
1127
         'email'    => '[email protected]',
1128
         'roles'    => array( 'baby' ),
1129
        );
1130
1131
        $request = new WP_REST_Request('POST', '/wp/v2/users');
1132
        $request->add_header('content-type', 'application/x-www-form-urlencoded');
1133
        $request->set_body_params($params);
1134
        $response = $this->server->dispatch($request);
1135
1136
        $this->assertErrorResponse('rest_user_invalid_role', $response, 400);
1137
    }
1138
1139
    public function test_update_item() 
@@ 1520-1537 (lines=18) @@
1517
        $this->assertErrorResponse('rest_user_invalid_argument', $response, 400);
1518
    }
1519
1520
    public function test_update_user_invalid_id() 
1521
    {
1522
        $this->allow_user_to_manage_multisite();
1523
        wp_set_current_user(self::$user);
1524
1525
        $params = array(
1526
         'id'       => '156',
1527
         'username' => 'lisasimpson',
1528
         'password' => 'DavidHasselhoff',
1529
         'email'    => '[email protected]',
1530
        );
1531
1532
        $request = new WP_REST_Request('PUT', sprintf('/wp/v2/users/%d', self::$editor));
1533
        $request->add_header('content-type', 'application/x-www-form-urlencoded');
1534
        $request->set_body_params($params);
1535
        $response = $this->server->dispatch($request);
1536
1537
        $this->assertErrorResponse('rest_user_invalid_id', $response, 404);
1538
    }
1539
1540
    public function test_update_item_invalid_password()