Code Duplication    Length = 15-18 lines in 3 locations

tests/phpunit/tests/rest-api/rest-posts-controller.php 3 locations

@@ 1409-1426 (lines=18) @@
1406
        $this->assertEquals('private', $new_post->post_status);
1407
    }
1408
1409
    public function test_create_post_private_without_permission() 
1410
    {
1411
        wp_set_current_user(self::$author_id);
1412
        $user = wp_get_current_user();
1413
        $user->add_cap('publish_posts', false);
1414
        // Flush capabilities, https://core.trac.wordpress.org/ticket/28374
1415
        $user->get_role_caps();
1416
        $user->update_user_level_from_caps();
1417
1418
        $request = new WP_REST_Request('POST', '/wp/v2/posts');
1419
        $params = $this->set_post_data(
1420
            array(
1421
            'status' => 'private',
1422
            'author' => self::$author_id,
1423
            ) 
1424
        );
1425
        $request->set_body_params($params);
1426
        $response = $this->server->dispatch($request);
1427
1428
        $this->assertErrorResponse('rest_cannot_publish', $response, 403);
1429
    }
@@ 1431-1447 (lines=17) @@
1428
        $this->assertErrorResponse('rest_cannot_publish', $response, 403);
1429
    }
1430
1431
    public function test_create_post_publish_without_permission() 
1432
    {
1433
        wp_set_current_user(self::$author_id);
1434
        $user = wp_get_current_user();
1435
        $user->add_cap('publish_posts', false);
1436
        // Flush capabilities, https://core.trac.wordpress.org/ticket/28374
1437
        $user->get_role_caps();
1438
        $user->update_user_level_from_caps();
1439
1440
        $request = new WP_REST_Request('POST', '/wp/v2/posts');
1441
        $params = $this->set_post_data(
1442
            array(
1443
            'status' => 'publish',
1444
            ) 
1445
        );
1446
        $request->set_body_params($params);
1447
        $response = $this->server->dispatch($request);
1448
1449
        $this->assertErrorResponse('rest_cannot_publish', $response, 403);
1450
    }
@@ 1649-1663 (lines=15) @@
1646
        $this->assertEquals('0', $data['password']);
1647
    }
1648
1649
    public function test_create_post_with_empty_string_password_and_sticky() 
1650
    {
1651
        wp_set_current_user(self::$editor_id);
1652
1653
        $request = new WP_REST_Request('POST', '/wp/v2/posts');
1654
        $params = $this->set_post_data(
1655
            array(
1656
            'password' => '',
1657
            'sticky'   => true,
1658
            ) 
1659
        );
1660
        $request->set_body_params($params);
1661
        $response = $this->server->dispatch($request);
1662
1663
        $this->assertEquals(201, $response->get_status());
1664
        $data = $response->get_data();
1665
        $this->assertEquals('', $data['password']);
1666
    }