Code Duplication    Length = 26-27 lines in 2 locations

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

@@ 141-167 (lines=27) @@
138
		$this->assertEqualSets( $media_types, $data['endpoints'][0]['args']['media_type']['enum'] );
139
	}
140
141
	public function test_get_items() {
142
		wp_set_current_user( 0 );
143
		$id1 = $this->factory->attachment->create_object( $this->test_file, 0, array(
144
			'post_mime_type' => 'image/jpeg',
145
			'post_excerpt'   => 'A sample caption',
146
		) );
147
		$draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );
148
		$id2 = $this->factory->attachment->create_object( $this->test_file, $draft_post, array(
149
			'post_mime_type' => 'image/jpeg',
150
			'post_excerpt'   => 'A sample caption',
151
		) );
152
		$published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) );
153
		$id3 = $this->factory->attachment->create_object( $this->test_file, $published_post, array(
154
			'post_mime_type' => 'image/jpeg',
155
			'post_excerpt'   => 'A sample caption',
156
		) );
157
		$request = new WP_REST_Request( 'GET', '/wp/v2/media' );
158
		$response = $this->server->dispatch( $request );
159
		$data = $response->get_data();
160
		$this->assertCount( 2, $data );
161
		$ids = wp_list_pluck( $data, 'id' );
162
		$this->assertTrue( in_array( $id1, $ids ) );
163
		$this->assertFalse( in_array( $id2, $ids ) );
164
		$this->assertTrue( in_array( $id3, $ids ) );
165
166
		$this->check_get_posts_response( $response );
167
	}
168
169
	public function test_get_items_logged_in_editor() {
170
		wp_set_current_user( $this->editor_id );
@@ 169-194 (lines=26) @@
166
		$this->check_get_posts_response( $response );
167
	}
168
169
	public function test_get_items_logged_in_editor() {
170
		wp_set_current_user( $this->editor_id );
171
		$id1 = $this->factory->attachment->create_object( $this->test_file, 0, array(
172
			'post_mime_type' => 'image/jpeg',
173
			'post_excerpt'   => 'A sample caption',
174
		) );
175
		$draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );
176
		$id2 = $this->factory->attachment->create_object( $this->test_file, $draft_post, array(
177
			'post_mime_type' => 'image/jpeg',
178
			'post_excerpt'   => 'A sample caption',
179
		) );
180
		$published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) );
181
		$id3 = $this->factory->attachment->create_object( $this->test_file, $published_post, array(
182
			'post_mime_type' => 'image/jpeg',
183
			'post_excerpt'   => 'A sample caption',
184
		) );
185
		$request = new WP_REST_Request( 'GET', '/wp/v2/media' );
186
		$response = $this->server->dispatch( $request );
187
188
		$data = $response->get_data();
189
		$this->assertCount( 3, $data );
190
		$ids = wp_list_pluck( $data, 'id' );
191
		$this->assertTrue( in_array( $id1, $ids ) );
192
		$this->assertTrue( in_array( $id2, $ids ) );
193
		$this->assertTrue( in_array( $id3, $ids ) );
194
	}
195
196
	public function test_get_items_media_type() {
197
		$id1 = $this->factory->attachment->create_object( $this->test_file, 0, array(