@@ 500-512 (lines=13) @@ | ||
497 | $this->check_comment_data( $data, 'view', $response->get_links() ); |
|
498 | } |
|
499 | ||
500 | public function test_prepare_item() { |
|
501 | wp_set_current_user( $this->admin_id ); |
|
502 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) ); |
|
503 | $request->set_query_params( array( |
|
504 | 'context' => 'edit', |
|
505 | ) ); |
|
506 | ||
507 | $response = $this->server->dispatch( $request ); |
|
508 | $this->assertEquals( 200, $response->get_status() ); |
|
509 | ||
510 | $data = $response->get_data(); |
|
511 | $this->check_comment_data( $data, 'edit', $response->get_links() ); |
|
512 | } |
|
513 | ||
514 | public function test_get_comment_author_avatar_urls() { |
|
515 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) ); |
@@ 1569-1577 (lines=9) @@ | ||
1566 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1567 | } |
|
1568 | ||
1569 | public function test_delete_item_already_trashed() { |
|
1570 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
1571 | wp_set_current_user( $this->editor_id ); |
|
1572 | $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); |
|
1573 | $response = $this->server->dispatch( $request ); |
|
1574 | $this->assertEquals( 200, $response->get_status() ); |
|
1575 | $response = $this->server->dispatch( $request ); |
|
1576 | $this->assertErrorResponse( 'rest_already_trashed', $response, 410 ); |
|
1577 | } |
|
1578 | ||
1579 | public function test_delete_post_invalid_id() { |
|
1580 | wp_set_current_user( $this->editor_id ); |
@@ 512-523 (lines=12) @@ | ||
509 | $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 ); |
|
510 | } |
|
511 | ||
512 | public function test_get_current_user() { |
|
513 | wp_set_current_user( $this->user ); |
|
514 | ||
515 | $request = new WP_REST_Request( 'GET', '/wp/v2/users/me' ); |
|
516 | ||
517 | $response = $this->server->dispatch( $request ); |
|
518 | $this->assertEquals( 302, $response->get_status() ); |
|
519 | ||
520 | $headers = $response->get_headers(); |
|
521 | $this->assertArrayHasKey( 'Location', $headers ); |
|
522 | $this->assertEquals( rest_url( '/wp/v2/users/' . $this->user ), $headers['Location'] ); |
|
523 | } |
|
524 | ||
525 | public function test_get_current_user_without_permission() { |
|
526 | wp_set_current_user( 0 ); |