@@ 528-539 (lines=12) @@ | ||
525 | $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 ); |
|
526 | } |
|
527 | ||
528 | public function test_get_current_user() { |
|
529 | wp_set_current_user( $this->user ); |
|
530 | ||
531 | $request = new WP_REST_Request( 'GET', '/wp/v2/users/me' ); |
|
532 | ||
533 | $response = $this->server->dispatch( $request ); |
|
534 | $this->assertEquals( 302, $response->get_status() ); |
|
535 | ||
536 | $headers = $response->get_headers(); |
|
537 | $this->assertArrayHasKey( 'Location', $headers ); |
|
538 | $this->assertEquals( rest_url( 'wp/v2/users/' . $this->user ), $headers['Location'] ); |
|
539 | } |
|
540 | ||
541 | public function test_get_current_user_without_permission() { |
|
542 | wp_set_current_user( 0 ); |
@@ 522-534 (lines=13) @@ | ||
519 | $this->check_comment_data( $data, 'view', $response->get_links() ); |
|
520 | } |
|
521 | ||
522 | public function test_prepare_item() { |
|
523 | wp_set_current_user( $this->admin_id ); |
|
524 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) ); |
|
525 | $request->set_query_params( array( |
|
526 | 'context' => 'edit', |
|
527 | ) ); |
|
528 | ||
529 | $response = $this->server->dispatch( $request ); |
|
530 | $this->assertEquals( 200, $response->get_status() ); |
|
531 | ||
532 | $data = $response->get_data(); |
|
533 | $this->check_comment_data( $data, 'edit', $response->get_links() ); |
|
534 | } |
|
535 | ||
536 | public function test_get_comment_author_avatar_urls() { |
|
537 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) ); |
@@ 1595-1603 (lines=9) @@ | ||
1592 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1593 | } |
|
1594 | ||
1595 | public function test_delete_item_already_trashed() { |
|
1596 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
1597 | wp_set_current_user( $this->editor_id ); |
|
1598 | $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); |
|
1599 | $response = $this->server->dispatch( $request ); |
|
1600 | $this->assertEquals( 200, $response->get_status() ); |
|
1601 | $response = $this->server->dispatch( $request ); |
|
1602 | $this->assertErrorResponse( 'rest_already_trashed', $response, 410 ); |
|
1603 | } |
|
1604 | ||
1605 | public function test_delete_post_invalid_id() { |
|
1606 | wp_set_current_user( $this->editor_id ); |