Make WordPress Core


Ignore:
Timestamp:
11/23/2016 11:12:05 PM (8 years ago)
Author:
joehoyle
Message:

REST API: Allow unsetting a post’s password.

Props danielbachhuber, iseulde.
Fixes #38919.

File:
1 edited

Legend:

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

    r39343 r39352  
    19481948        $new_data = $response->get_data();
    19491949        $this->assertEquals( '', $new_data['content']['raw'] );
     1950    }
     1951
     1952    public function test_update_post_with_empty_password() {
     1953        wp_set_current_user( self::$editor_id );
     1954        wp_update_post( array(
     1955            'ID'            => self::$post_id,
     1956            'post_password' => 'foo',
     1957        ) );
     1958
     1959        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     1960        $params = $this->set_post_data( array(
     1961            'password' => '',
     1962        ) );
     1963        $request->set_body_params( $params );
     1964        $response = $this->server->dispatch( $request );
     1965        $data = $response->get_data();
     1966        $this->assertEquals( '', $data['password'] );
    19501967    }
    19511968
Note: See TracChangeset for help on using the changeset viewer.