| @@ 499-517 (lines=19) @@ | ||
| 496 | $this->assertTrue($data['excerpt']['protected']); |
|
| 497 | } |
|
| 498 | ||
| 499 | public function test_get_page_with_password_using_password() |
|
| 500 | { |
|
| 501 | $page_id = $this->factory->post->create( |
|
| 502 | array( |
|
| 503 | 'post_type' => 'page', |
|
| 504 | 'post_password' => '$inthebananastand', |
|
| 505 | 'post_content' => 'Some secret content.', |
|
| 506 | 'post_excerpt' => 'Some secret excerpt.', |
|
| 507 | ) |
|
| 508 | ); |
|
| 509 | ||
| 510 | $page = get_post($page_id); |
|
| 511 | $request = new WP_REST_Request('GET', sprintf('/wp/v2/pages/%d', $page_id)); |
|
| 512 | $request->set_param('password', '$inthebananastand'); |
|
| 513 | $response = $this->server->dispatch($request); |
|
| 514 | ||
| 515 | $data = $response->get_data(); |
|
| 516 | $this->assertEquals(wpautop($page->post_content), $data['content']['rendered']); |
|
| 517 | $this->assertTrue($data['content']['protected']); |
|
| 518 | $this->assertEquals(wpautop($page->post_excerpt), $data['excerpt']['rendered']); |
|
| 519 | $this->assertTrue($data['excerpt']['protected']); |
|
| 520 | } |
|
| @@ 1080-1099 (lines=20) @@ | ||
| 1077 | $this->assertTrue($data['excerpt']['protected']); |
|
| 1078 | } |
|
| 1079 | ||
| 1080 | public function test_get_post_with_password_using_password() |
|
| 1081 | { |
|
| 1082 | $post_id = $this->factory->post->create( |
|
| 1083 | array( |
|
| 1084 | 'post_password' => '$inthebananastand', |
|
| 1085 | 'post_content' => 'Some secret content.', |
|
| 1086 | 'post_excerpt' => 'Some secret excerpt.', |
|
| 1087 | ) |
|
| 1088 | ); |
|
| 1089 | ||
| 1090 | $post = get_post($post_id); |
|
| 1091 | $request = new WP_REST_Request('GET', sprintf('/wp/v2/posts/%d', $post_id)); |
|
| 1092 | $request->set_param('password', '$inthebananastand'); |
|
| 1093 | $response = $this->server->dispatch($request); |
|
| 1094 | ||
| 1095 | $this->check_get_post_response($response, 'view'); |
|
| 1096 | ||
| 1097 | $data = $response->get_data(); |
|
| 1098 | $this->assertEquals(wpautop($post->post_content), $data['content']['rendered']); |
|
| 1099 | $this->assertTrue($data['content']['protected']); |
|
| 1100 | $this->assertEquals(wpautop($post->post_excerpt), $data['excerpt']['rendered']); |
|
| 1101 | $this->assertTrue($data['excerpt']['protected']); |
|
| 1102 | } |
|