Changeset 39047
- Timestamp:
- 10/31/2016 03:52:08 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r39011 r39047 420 420 ); 421 421 422 unset( $schema['properties']['password'] ); 423 422 424 return $schema; 423 425 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r39046 r39047 1748 1748 'readonly' => true, 1749 1749 ), 1750 'password' => array( 1751 'description' => __( 'A password to protect access to the content and excerpt.' ), 1752 'type' => 'string', 1753 'context' => array( 'edit' ), 1754 ), 1750 1755 ), 1751 1756 ); … … 1949 1954 'context' => array( 'view', 'edit' ), 1950 1955 ); 1951 1952 $schema['properties']['password'] = array(1953 'description' => __( 'A password to protect access to the content and excerpt.' ),1954 'type' => 'string',1955 'context' => array( 'edit' ),1956 );1957 1956 } 1958 1957 -
trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php
r38975 r39047 359 359 } 360 360 361 public function test_get_page_with_password() { 362 $page_id = $this->factory->post->create( array( 363 'post_type' => 'page', 364 'post_password' => '$inthebananastand', 365 ) ); 366 367 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 368 $response = $this->server->dispatch( $request ); 369 370 $data = $response->get_data(); 371 $this->assertEquals( '', $data['content']['rendered'] ); 372 $this->assertTrue( $data['content']['protected'] ); 373 $this->assertEquals( '', $data['excerpt']['rendered'] ); 374 $this->assertTrue( $data['excerpt']['protected'] ); 375 } 376 377 public function test_get_page_with_password_using_password() { 378 $page_id = $this->factory->post->create( array( 379 'post_type' => 'page', 380 'post_password' => '$inthebananastand', 381 'post_content' => 'Some secret content.', 382 'post_excerpt' => 'Some secret excerpt.', 383 ) ); 384 385 $page = get_post( $page_id ); 386 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 387 $request->set_param( 'password', '$inthebananastand' ); 388 $response = $this->server->dispatch( $request ); 389 390 $data = $response->get_data(); 391 $this->assertEquals( wpautop( $page->post_content ), $data['content']['rendered'] ); 392 $this->assertTrue( $data['content']['protected'] ); 393 $this->assertEquals( wpautop( $page->post_excerpt ), $data['excerpt']['rendered'] ); 394 $this->assertTrue( $data['excerpt']['protected'] ); 395 } 396 397 public function test_get_page_with_password_using_incorrect_password() { 398 $page_id = $this->factory->post->create( array( 399 'post_type' => 'page', 400 'post_password' => '$inthebananastand', 401 ) ); 402 403 $page = get_post( $page_id ); 404 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 405 $request->set_param( 'password', 'wrongpassword' ); 406 $response = $this->server->dispatch( $request ); 407 408 $this->assertErrorResponse( 'rest_post_incorrect_password', $response, 403 ); 409 } 410 411 public function test_get_page_with_password_without_permission() { 412 $page_id = $this->factory->post->create( array( 413 'post_type' => 'page', 414 'post_password' => '$inthebananastand', 415 'post_content' => 'Some secret content.', 416 'post_excerpt' => 'Some secret excerpt.', 417 ) ); 418 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 419 $response = $this->server->dispatch( $request ); 420 $data = $response->get_data(); 421 $this->assertEquals( '', $data['content']['rendered'] ); 422 $this->assertTrue( $data['content']['protected'] ); 423 $this->assertEquals( '', $data['excerpt']['rendered'] ); 424 $this->assertTrue( $data['excerpt']['protected'] ); 425 } 426 361 427 public function test_get_item_schema() { 362 428 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' ); … … 364 430 $data = $response->get_data(); 365 431 $properties = $data['schema']['properties']; 366 $this->assertEquals( 2 1, count( $properties ) );432 $this->assertEquals( 22, count( $properties ) ); 367 433 $this->assertArrayHasKey( 'author', $properties ); 368 434 $this->assertArrayHasKey( 'comment_status', $properties ); … … 380 446 $this->assertArrayHasKey( 'modified_gmt', $properties ); 381 447 $this->assertArrayHasKey( 'parent', $properties ); 448 $this->assertArrayHasKey( 'password', $properties ); 382 449 $this->assertArrayHasKey( 'ping_status', $properties ); 383 450 $this->assertArrayHasKey( 'slug', $properties ); -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r38975 r39047 771 771 772 772 $data = $response->get_data(); 773 $this->assertEquals( '', $data['content']['rendered'] ); 773 774 $this->assertTrue( $data['content']['protected'] ); 775 $this->assertEquals( '', $data['excerpt']['rendered'] ); 774 776 $this->assertTrue( $data['excerpt']['protected'] ); 775 777 } … … 791 793 $data = $response->get_data(); 792 794 $this->assertEquals( wpautop( $post->post_content ), $data['content']['rendered'] ); 795 $this->assertTrue( $data['content']['protected'] ); 793 796 $this->assertEquals( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] ); 797 $this->assertTrue( $data['excerpt']['protected'] ); 794 798 } 795 799 … … 818 822 $this->check_get_post_response( $response, 'view' ); 819 823 $this->assertEquals( '', $data['content']['rendered'] ); 824 $this->assertTrue( $data['content']['protected'] ); 820 825 $this->assertEquals( '', $data['excerpt']['rendered'] ); 821 826 $this->assertTrue( $data['excerpt']['protected'] ); 822 827 } 823 828
Note: See TracChangeset
for help on using the changeset viewer.