Code Duplication    Length = 12-19 lines in 4 locations

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

@@ 382-399 (lines=18) @@
379
        }
380
    }
381
382
    public function test_update_page_menu_order() 
383
    {
384
385
        $page_id = $this->factory->post->create(
386
            array(
387
            'post_type' => 'page',
388
            ) 
389
        );
390
391
        wp_set_current_user(self::$editor_id);
392
393
        $request = new WP_REST_Request('PUT', sprintf('/wp/v2/pages/%d', $page_id));
394
395
        $request->set_body_params(
396
            array(
397
            'menu_order' => 1,
398
            ) 
399
        );
400
        $response = $this->server->dispatch($request);
401
402
        $new_data = $response->get_data();
@@ 406-424 (lines=19) @@
403
        $this->assertEquals(1, $new_data['menu_order']);
404
    }
405
406
    public function test_update_page_menu_order_to_zero() 
407
    {
408
409
        $page_id = $this->factory->post->create(
410
            array(
411
            'post_type'  => 'page',
412
            'menu_order' => 1,
413
            ) 
414
        );
415
416
        wp_set_current_user(self::$editor_id);
417
418
        $request = new WP_REST_Request('PUT', sprintf('/wp/v2/pages/%d', $page_id));
419
420
        $request->set_body_params(
421
            array(
422
            'menu_order' => 0,
423
            )
424
        );
425
        $response = $this->server->dispatch($request);
426
427
        $new_data = $response->get_data();
@@ 522-534 (lines=13) @@
519
        $this->assertTrue($data['excerpt']['protected']);
520
    }
521
522
    public function test_get_page_with_password_using_incorrect_password() 
523
    {
524
        $page_id = $this->factory->post->create(
525
            array(
526
            'post_type'     => 'page',
527
            'post_password' => '$inthebananastand',
528
            ) 
529
        );
530
531
        $page = get_post($page_id);
532
        $request = new WP_REST_Request('GET', sprintf('/wp/v2/pages/%d', $page_id));
533
        $request->set_param('password', 'wrongpassword');
534
        $response = $this->server->dispatch($request);
535
536
        $this->assertErrorResponse('rest_post_incorrect_password', $response, 403);
537
    }

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

@@ 1104-1115 (lines=12) @@
1101
        $this->assertTrue($data['excerpt']['protected']);
1102
    }
1103
1104
    public function test_get_post_with_password_using_incorrect_password() 
1105
    {
1106
        $post_id = $this->factory->post->create(
1107
            array(
1108
            'post_password' => '$inthebananastand',
1109
            ) 
1110
        );
1111
1112
        $post = get_post($post_id);
1113
        $request = new WP_REST_Request('GET', sprintf('/wp/v2/posts/%d', $post_id));
1114
        $request->set_param('password', 'wrongpassword');
1115
        $response = $this->server->dispatch($request);
1116
1117
        $this->assertErrorResponse('rest_post_incorrect_password', $response, 403);
1118
    }