From 37c4f28390c0ad2d4fb506d3dca078d2d83ff54b Mon Sep 17 00:00:00 2001
From: Himani <himaniwork3010@gmail.com>
Date: Mon, 25 Nov 2019 12:14:07 +0530
Subject: [PATCH] #42238 Unit test case
---
.../rest-api/rest-comments-controller.php | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php
index da2d372a54..b85177f7f3 100644
|
a
|
b
|
class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase |
| 3240 | 3240 | $this->assertArrayNotHasKey( 'raw', $data['content'] ); |
| 3241 | 3241 | } |
| 3242 | 3242 | } |
| | 3243 | |
| | 3244 | /** |
| | 3245 | * @ticket 42238 |
| | 3246 | */ |
| | 3247 | public function test_check_read_post_permission_with_invalid_post_type() { |
| | 3248 | regisrer_post_type( |
| | 3249 | 'bug-post', |
| | 3250 | array( |
| | 3251 | 'label' => 'Bug Posts', |
| | 3252 | 'supports' => array( 'title', 'editor', 'author', 'excerpt', 'comments', 'revisions' ), |
| | 3253 | 'show_in_rest' => true, |
| | 3254 | 'public' => true, |
| | 3255 | 'has_archive' => true, |
| | 3256 | ) |
| | 3257 | ); |
| | 3258 | create_initial_rest_routes(); |
| | 3259 | |
| | 3260 | wp_set_current_user( self::$admin_id ); |
| | 3261 | |
| | 3262 | self::$post_id = $factory->post->create( |
| | 3263 | array( |
| | 3264 | 'post_title' => 'Bug Post', |
| | 3265 | 'post_type' => 'bug-post', |
| | 3266 | 'post_status' => 'publish', |
| | 3267 | ) |
| | 3268 | ); |
| | 3269 | |
| | 3270 | $this->factory->comment->create_post_comments( self::$post_id, 2 ); |
| | 3271 | |
| | 3272 | $request = new WP_REST_REQUEST( 'GET', '/wp/v2/comments' ); |
| | 3273 | |
| | 3274 | $response = rest_get_server()->dispatch( $request ); |
| | 3275 | $this->assertEquals( 200, $response->get_status() ); |
| | 3276 | |
| | 3277 | _unregister_post_type( 'bug-post' ); |
| | 3278 | |
| | 3279 | $request = new WP_REST_REQUEST( 'GET', '/wp/v2/comments' ); |
| | 3280 | $response = rest_get_server()->dispatch( $request ); |
| | 3281 | $this->assertEquals( 200, $response->get_status() ); |
| | 3282 | |
| | 3283 | } |
| 3243 | 3284 | } |