@@ 520-530 (lines=11) @@ | ||
517 | $this->assertErrorResponse( 'rest_cannot_edit', $response, 403 ); |
|
518 | } |
|
519 | ||
520 | public function test_create_item_invalid_post_type() { |
|
521 | $attachment_id = $this->factory->post->create( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_parent' => 0 ) ); |
|
522 | wp_set_current_user( $this->editor_id ); |
|
523 | $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); |
|
524 | $request->set_header( 'Content-Type', 'image/jpeg' ); |
|
525 | $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); |
|
526 | $request->set_body( file_get_contents( $this->test_file ) ); |
|
527 | $request->set_param( 'post', $attachment_id ); |
|
528 | $response = $this->server->dispatch( $request ); |
|
529 | $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); |
|
530 | } |
|
531 | ||
532 | public function test_create_item_alt_text() { |
|
533 | wp_set_current_user( $this->author_id ); |
@@ 346-356 (lines=11) @@ | ||
343 | $this->assertEquals( $adam_id, $data[0]['id'] ); |
|
344 | } |
|
345 | ||
346 | public function test_get_items_slug_query() { |
|
347 | wp_set_current_user( $this->user ); |
|
348 | $this->factory->user->create( array( 'display_name' => 'foo', 'user_login' => 'bar' ) ); |
|
349 | $id2 = $this->factory->user->create( array( 'display_name' => 'Moo', 'user_login' => 'foo' ) ); |
|
350 | $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); |
|
351 | $request->set_param( 'slug', 'foo' ); |
|
352 | $response = $this->server->dispatch( $request ); |
|
353 | $data = $response->get_data(); |
|
354 | $this->assertEquals( 1, count( $data ) ); |
|
355 | $this->assertEquals( $id2, $data[0]['id'] ); |
|
356 | } |
|
357 | ||
358 | // Note: Do not test using editor role as there is an editor role created in testing and it makes it hard to test this functionality. |
|
359 | public function test_get_items_roles() { |