Code Duplication    Length = 18-18 lines in 2 locations

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

@@ 1860-1877 (lines=18) @@
1857
    /**
1858
     * @ticket 38505
1859
     */
1860
    public function test_create_post_with_categories_that_cannot_be_assigned_by_current_user() 
1861
    {
1862
        $cats = self::factory()->category->create_many(2);
1863
        $this->forbidden_cat = $cats[1];
1864
1865
        wp_set_current_user(self::$editor_id);
1866
        $request = new WP_REST_Request('POST', '/wp/v2/posts');
1867
        $params = $this->set_post_data(
1868
            array(
1869
            'password'   => 'testing',
1870
            'categories' => $cats,
1871
            ) 
1872
        );
1873
        $request->set_body_params($params);
1874
1875
        add_filter('map_meta_cap', array( $this, 'revoke_assign_term' ), 10, 4);
1876
        $response = $this->server->dispatch($request);
1877
        remove_filter('map_meta_cap', array( $this, 'revoke_assign_term' ), 10, 4);
1878
1879
        $this->assertErrorResponse('rest_cannot_assign_term', $response, 403);
1880
    }
@@ 2466-2483 (lines=18) @@
2463
    /**
2464
     * @ticket 38505
2465
     */
2466
    public function test_update_post_with_categories_that_cannot_be_assigned_by_current_user() 
2467
    {
2468
        $cats = self::factory()->category->create_many(2);
2469
        $this->forbidden_cat = $cats[1];
2470
2471
        wp_set_current_user(self::$editor_id);
2472
        $request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id));
2473
        $params = $this->set_post_data(
2474
            array(
2475
            'password'   => 'testing',
2476
            'categories' => $cats,
2477
            ) 
2478
        );
2479
        $request->set_body_params($params);
2480
2481
        add_filter('map_meta_cap', array( $this, 'revoke_assign_term' ), 10, 4);
2482
        $response = $this->server->dispatch($request);
2483
        remove_filter('map_meta_cap', array( $this, 'revoke_assign_term' ), 10, 4);
2484
2485
        $this->assertErrorResponse('rest_cannot_assign_term', $response, 403);
2486
    }