mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
REST API: Special case the “standard” post format to always be allowed.
Fixes #38916. git-svn-id: https://develop.svn.wordpress.org/trunk@39353 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1287,6 +1287,22 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$this->assertEquals( 'gallery', get_post_format( $new_post->ID ) );
|
||||
}
|
||||
|
||||
public function test_create_post_with_standard_format() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
$request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
|
||||
$params = $this->set_post_data( array(
|
||||
'format' => 'standard',
|
||||
) );
|
||||
$request->set_body_params( $params );
|
||||
$response = $this->server->dispatch( $request );
|
||||
|
||||
$data = $response->get_data();
|
||||
$new_post = get_post( $data['id'] );
|
||||
$this->assertEquals( 'standard', $data['format'] );
|
||||
$this->assertFalse( get_post_format( $new_post->ID ) );
|
||||
}
|
||||
|
||||
public function test_create_post_with_invalid_format() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
@@ -1753,6 +1769,22 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$this->assertEquals( 'gallery', get_post_format( $new_post->ID ) );
|
||||
}
|
||||
|
||||
public function test_update_post_with_standard_format() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
|
||||
$params = $this->set_post_data( array(
|
||||
'format' => 'standard',
|
||||
) );
|
||||
$request->set_body_params( $params );
|
||||
$response = $this->server->dispatch( $request );
|
||||
|
||||
$data = $response->get_data();
|
||||
$new_post = get_post( $data['id'] );
|
||||
$this->assertEquals( 'standard', $data['format'] );
|
||||
$this->assertFalse( get_post_format( $new_post->ID ) );
|
||||
}
|
||||
|
||||
public function test_update_post_with_invalid_format() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user