Code Duplication    Length = 9-13 lines in 3 locations

tests/test-rest-post-statuses-controller.php 1 location

@@ 26-34 (lines=9) @@
23
		$this->assertEqualSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
24
	}
25
26
	public function test_get_items() {
27
		$request = new WP_REST_Request( 'GET', '/wp/v2/statuses' );
28
		$response = $this->server->dispatch( $request );
29
30
		$data = $response->get_data();
31
		$statuses = get_post_stati( array( 'public' => true ), 'objects' );
32
		$this->assertEquals( 1, count( $data ) );
33
		$this->assertEquals( 'publish', $data['publish']['slug'] );
34
	}
35
36
	public function test_get_items_logged_in() {
37
		$user_id = $this->factory->user->create( array( 'role' => 'author' ) );

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

@@ 1166-1178 (lines=13) @@
1163
		$this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
1164
	}
1165
1166
	public function test_update_comment_invalid_id() {
1167
		wp_set_current_user( 0 );
1168
1169
		$params = array(
1170
			'content' => 'Oh, they have the internet on computers now!',
1171
		);
1172
		$request = new WP_REST_Request( 'PUT', '/wp/v2/comments/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
1173
		$request->add_header( 'content-type', 'application/json' );
1174
		$request->set_body( wp_json_encode( $params ) );
1175
1176
		$response = $this->server->dispatch( $request );
1177
		$this->assertErrorResponse( 'rest_comment_invalid_id', $response, 404 );
1178
	}
1179
1180
	public function test_update_comment_invalid_permission() {
1181
		wp_set_current_user( 0 );
@@ 1180-1192 (lines=13) @@
1177
		$this->assertErrorResponse( 'rest_comment_invalid_id', $response, 404 );
1178
	}
1179
1180
	public function test_update_comment_invalid_permission() {
1181
		wp_set_current_user( 0 );
1182
1183
		$params = array(
1184
			'content' => 'Disco Stu likes disco music.',
1185
		);
1186
		$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->hold_id ) );
1187
		$request->add_header( 'content-type', 'application/json' );
1188
		$request->set_body( wp_json_encode( $params ) );
1189
1190
		$response = $this->server->dispatch( $request );
1191
		$this->assertErrorResponse( 'rest_cannot_edit', $response, 401 );
1192
	}
1193
1194
	public function test_update_comment_with_children_link() {
1195
		wp_set_current_user( $this->admin_id );