Code Duplication    Length = 11-12 lines in 3 locations

tests/test-rest-attachments-controller.php 3 locations

@@ 393-403 (lines=11) @@
390
		$this->assertFalse( isset( $data['media_details']['sizes']['rest-api-test']['source_url'] ) );
391
	}
392
393
	public function test_get_item_private_post() {
394
		wp_set_current_user( 0 );
395
		$draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );
396
		$id1 = $this->factory->attachment->create_object( $this->test_file, $draft_post, array(
397
			'post_mime_type' => 'image/jpeg',
398
			'post_excerpt'   => 'A sample caption',
399
		) );
400
		$request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $id1 );
401
		$response = $this->server->dispatch( $request );
402
		$this->assertEquals( 403, $response->get_status() );
403
	}
404
405
	public function test_create_item() {
406
		wp_set_current_user( $this->author_id );
@@ 603-614 (lines=12) @@
600
		$this->assertEquals( $new_parent, $attachment->post_parent );
601
	}
602
603
	public function test_update_item_invalid_permissions() {
604
		wp_set_current_user( $this->author_id );
605
		$attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, array(
606
			'post_mime_type' => 'image/jpeg',
607
			'post_excerpt'   => 'A sample caption',
608
			'post_author'    => $this->editor_id,
609
		) );
610
		$request = new WP_REST_Request( 'POST', '/wp/v2/media/' . $attachment_id );
611
		$request->set_param( 'caption', 'This is a better caption.' );
612
		$response = $this->server->dispatch( $request );
613
		$this->assertErrorResponse( 'rest_cannot_edit', $response, 403 );
614
	}
615
616
	public function test_update_item_invalid_post_type() {
617
		$attachment_id = $this->factory->post->create( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_parent' => 0 ) );
@@ 659-669 (lines=11) @@
656
		$this->assertNotEmpty( $post );
657
	}
658
659
	public function test_delete_item_invalid_delete_permissions() {
660
		wp_set_current_user( $this->author_id );
661
		$attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, array(
662
			'post_mime_type' => 'image/jpeg',
663
			'post_excerpt'   => 'A sample caption',
664
			'post_author'    => $this->editor_id,
665
		) );
666
		$request = new WP_REST_Request( 'DELETE', '/wp/v2/media/' . $attachment_id );
667
		$response = $this->server->dispatch( $request );
668
		$this->assertErrorResponse( 'rest_cannot_delete', $response, 403 );
669
	}
670
671
	public function test_prepare_item() {
672
		$attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, array(