Make WordPress Core


Ignore:
Timestamp:
11/24/2016 12:07:50 AM (8 years ago)
Author:
joehoyle
Message:

REST API: Special case the “standard” post format to always be allowed.

Fixes #38916.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r39352 r39353  
    12881288    }
    12891289
     1290    public function test_create_post_with_standard_format() {
     1291        wp_set_current_user( self::$editor_id );
     1292
     1293        $request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
     1294        $params = $this->set_post_data( array(
     1295            'format' => 'standard',
     1296        ) );
     1297        $request->set_body_params( $params );
     1298        $response = $this->server->dispatch( $request );
     1299
     1300        $data = $response->get_data();
     1301        $new_post = get_post( $data['id'] );
     1302        $this->assertEquals( 'standard', $data['format'] );
     1303        $this->assertFalse( get_post_format( $new_post->ID ) );
     1304    }
     1305
    12901306    public function test_create_post_with_invalid_format() {
    12911307        wp_set_current_user( self::$editor_id );
     
    17521768        $this->assertEquals( 'gallery', $data['format'] );
    17531769        $this->assertEquals( 'gallery', get_post_format( $new_post->ID ) );
     1770    }
     1771
     1772    public function test_update_post_with_standard_format() {
     1773        wp_set_current_user( self::$editor_id );
     1774
     1775        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     1776        $params = $this->set_post_data( array(
     1777            'format' => 'standard',
     1778        ) );
     1779        $request->set_body_params( $params );
     1780        $response = $this->server->dispatch( $request );
     1781
     1782        $data = $response->get_data();
     1783        $new_post = get_post( $data['id'] );
     1784        $this->assertEquals( 'standard', $data['format'] );
     1785        $this->assertFalse( get_post_format( $new_post->ID ) );
    17541786    }
    17551787
Note: See TracChangeset for help on using the changeset viewer.