Ticket #38494: return-updated-post-on-trash.diff
File return-updated-post-on-trash.diff, 1.7 KB (added by , 8 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
754 754 // If we're forcing, then delete permanently. 755 755 if ( $force ) { 756 756 $result = wp_delete_post( $id, true ); 757 $response = true; 757 758 } else { 758 759 // If we don't support trashing for this type, error out. 759 760 if ( ! $supports_trash ) { … … 768 769 // (Note that internally this falls through to `wp_delete_post` if 769 770 // the trash is disabled.) 770 771 $result = wp_trash_post( $id ); 772 $post = $this->get_post( $id ); 773 $response = $this->prepare_item_for_response( $post, $request ); 771 774 } 772 775 773 776 if ( ! $result ) { -
tests/phpunit/tests/rest-api/rest-posts-controller.php
1781 1781 $this->assertEquals( 200, $response->get_status() ); 1782 1782 $data = $response->get_data(); 1783 1783 $this->assertEquals( 'Deleted post', $data['title']['raw'] ); 1784 $this->assertEquals( 'trash', $data['status'] ); 1784 1785 } 1785 1786 1786 1787 public function test_delete_item_skip_trash() { … … 1793 1794 1794 1795 $this->assertNotInstanceOf( 'WP_Error', $response ); 1795 1796 $this->assertEquals( 200, $response->get_status() ); 1796 $data = $response->get_data(); 1797 $this->assertEquals( 'Deleted post', $data['title']['raw'] ); 1797 $this->assertTrue( $response->get_data() ); 1798 1798 } 1799 1799 1800 1800 public function test_delete_item_already_trashed() {