- Timestamp:
- 08/03/2022 09:01:05 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r53759 r53813 5237 5237 } 5238 5238 5239 /** 5240 * @ticket 52422 5241 * 5242 * @covers WP_REST_Request::create_item 5243 */ 5244 public function test_draft_post_do_not_have_the_same_slug_as_existing_post() { 5245 wp_set_current_user( self::$editor_id ); 5246 $this->factory()->post->create( array( 'post_name' => 'sample-slug' ) ); 5247 5248 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 5249 $params = $this->set_post_data( 5250 array( 5251 'status' => 'draft', 5252 'slug' => 'sample-slug', 5253 ) 5254 ); 5255 $request->set_body_params( $params ); 5256 $response = rest_get_server()->dispatch( $request ); 5257 5258 $new_data = $response->get_data(); 5259 $this->assertSame( 5260 'sample-slug-2', 5261 $new_data['slug'], 5262 'The slug from the REST response did not match' 5263 ); 5264 5265 $post = get_post( $new_data['id'] ); 5266 5267 $this->assertSame( 5268 'draft', 5269 $post->post_status, 5270 'The post status is not draft' 5271 ); 5272 5273 $this->assertSame( 5274 'sample-slug-2', 5275 $post->post_name, 5276 'The post slug was not set to "sample-slug-2"' 5277 ); 5278 } 5279 5239 5280 public function tear_down() { 5240 5281 if ( isset( $this->attachment_id ) ) {
Note: See TracChangeset
for help on using the changeset viewer.