mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-05 23:27:04 +00:00
REST API: Allow parent property to be explicitly set to 0 when creating or updating a Post.
Props lucasstark, danielbachhuber. Fixes #38852. git-svn-id: https://develop.svn.wordpress.org/trunk@39289 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -371,6 +371,41 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$this->assertEquals( 0, $new_data['menu_order'] );
|
||||
}
|
||||
|
||||
public function test_update_page_parent_non_zero() {
|
||||
$page_id1 = $this->factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
$page_id2 = $this->factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
wp_set_current_user( self::$editor_id );
|
||||
$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id2 ) );
|
||||
$request->set_body_params( array(
|
||||
'parent' => $page_id1,
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$new_data = $response->get_data();
|
||||
$this->assertEquals( $page_id1, $new_data['parent'] );
|
||||
}
|
||||
|
||||
public function test_update_page_parent_zero() {
|
||||
$page_id1 = $this->factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
$page_id2 = $this->factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_parent' => $page_id1,
|
||||
) );
|
||||
wp_set_current_user( self::$editor_id );
|
||||
$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id2 ) );
|
||||
$request->set_body_params( array(
|
||||
'parent' => 0,
|
||||
) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$new_data = $response->get_data();
|
||||
$this->assertEquals( 0, $new_data['parent'] );
|
||||
}
|
||||
|
||||
public function test_get_page_with_password() {
|
||||
$page_id = $this->factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
|
||||
Reference in New Issue
Block a user