| @@ 539-553 (lines=15) @@ | ||
| 536 | $this->assertErrorResponse('rest_post_incorrect_password', $response, 403); |
|
| 537 | } |
|
| 538 | ||
| 539 | public function test_get_page_with_password_without_permission() |
|
| 540 | { |
|
| 541 | $page_id = $this->factory->post->create( |
|
| 542 | array( |
|
| 543 | 'post_type' => 'page', |
|
| 544 | 'post_password' => '$inthebananastand', |
|
| 545 | 'post_content' => 'Some secret content.', |
|
| 546 | 'post_excerpt' => 'Some secret excerpt.', |
|
| 547 | ) |
|
| 548 | ); |
|
| 549 | $request = new WP_REST_Request('GET', sprintf('/wp/v2/pages/%d', $page_id)); |
|
| 550 | $response = $this->server->dispatch($request); |
|
| 551 | $data = $response->get_data(); |
|
| 552 | $this->assertEquals('', $data['content']['rendered']); |
|
| 553 | $this->assertTrue($data['content']['protected']); |
|
| 554 | $this->assertEquals('', $data['excerpt']['rendered']); |
|
| 555 | $this->assertTrue($data['excerpt']['protected']); |
|
| 556 | } |
|
| @@ 1120-1134 (lines=15) @@ | ||
| 1117 | $this->assertErrorResponse('rest_post_incorrect_password', $response, 403); |
|
| 1118 | } |
|
| 1119 | ||
| 1120 | public function test_get_post_with_password_without_permission() |
|
| 1121 | { |
|
| 1122 | $post_id = $this->factory->post->create( |
|
| 1123 | array( |
|
| 1124 | 'post_password' => '$inthebananastand', |
|
| 1125 | 'post_content' => 'Some secret content.', |
|
| 1126 | 'post_excerpt' => 'Some secret excerpt.', |
|
| 1127 | ) |
|
| 1128 | ); |
|
| 1129 | $request = new WP_REST_Request('GET', sprintf('/wp/v2/posts/%d', $post_id)); |
|
| 1130 | $response = $this->server->dispatch($request); |
|
| 1131 | $data = $response->get_data(); |
|
| 1132 | $this->check_get_post_response($response, 'view'); |
|
| 1133 | $this->assertEquals('', $data['content']['rendered']); |
|
| 1134 | $this->assertTrue($data['content']['protected']); |
|
| 1135 | $this->assertEquals('', $data['excerpt']['rendered']); |
|
| 1136 | $this->assertTrue($data['excerpt']['protected']); |
|
| 1137 | } |
|