@@ 747-763 (lines=17) @@ | ||
744 | $this->check_taxonomy_term( $term, $data, $response->get_links() ); |
|
745 | } |
|
746 | ||
747 | public function test_prepare_taxonomy_term_child() { |
|
748 | $child = $this->factory->category->create( array( |
|
749 | 'parent' => 1, |
|
750 | ) ); |
|
751 | $term = get_term( $child, 'category' ); |
|
752 | ||
753 | $request = new WP_REST_Request( 'GET', '/wp/v2/categories/' . $child ); |
|
754 | $response = $this->server->dispatch( $request ); |
|
755 | $data = $response->get_data(); |
|
756 | ||
757 | $this->check_taxonomy_term( $term, $data, $response->get_links() ); |
|
758 | ||
759 | $this->assertEquals( 1, $data['parent'] ); |
|
760 | ||
761 | $links = $response->get_links(); |
|
762 | $this->assertEquals( rest_url( 'wp/v2/categories/1' ), $links['up'][0]['href'] ); |
|
763 | } |
|
764 | ||
765 | public function test_get_item_schema() { |
|
766 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories' ); |
@@ 757-774 (lines=18) @@ | ||
754 | $this->assertErrorResponse( 'rest_cannot_create', $response, 401 ); |
|
755 | } |
|
756 | ||
757 | public function test_create_post_draft() { |
|
758 | wp_set_current_user( $this->editor_id ); |
|
759 | ||
760 | $request = new WP_REST_Request( 'POST', '/wp/v2/posts' ); |
|
761 | $params = $this->set_post_data( array( |
|
762 | 'status' => 'draft', |
|
763 | ) ); |
|
764 | $request->set_body_params( $params ); |
|
765 | $response = $this->server->dispatch( $request ); |
|
766 | ||
767 | $data = $response->get_data(); |
|
768 | $new_post = get_post( $data['id'] ); |
|
769 | $this->assertEquals( 'draft', $data['status'] ); |
|
770 | $this->assertEquals( 'draft', $new_post->post_status ); |
|
771 | // Confirm dates are null |
|
772 | $this->assertNull( $data['date_gmt'] ); |
|
773 | $this->assertNull( $data['modified_gmt'] ); |
|
774 | } |
|
775 | ||
776 | public function test_create_post_private() { |
|
777 | wp_set_current_user( $this->editor_id ); |