Changeset 43571 for trunk/tests/phpunit/tests/post/wpInsertPost.php
- Timestamp:
- 08/17/2018 01:50:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/wpInsertPost.php
r42380 r43571 13 13 static function wpSetUpBeforeClass( $factory ) { 14 14 self::$user_ids = array( 15 'administrator' => $factory->user->create( array( 16 'role' => 'administrator', 17 ) ), 18 'contributor' => $factory->user->create( array( 19 'role' => 'contributor', 20 ) ), 15 'administrator' => $factory->user->create( 16 array( 17 'role' => 'administrator', 18 ) 19 ), 20 'contributor' => $factory->user->create( 21 array( 22 'role' => 'contributor', 23 ) 24 ), 21 25 ); 22 26 … … 37 41 parent::setUp(); 38 42 39 register_post_type( 'mapped_meta_caps', array( 40 'capability_type' => array( 'mapped_meta_cap', 'mapped_meta_caps' ), 41 'map_meta_cap' => true, 42 ) ); 43 44 register_post_type( 'unmapped_meta_caps', array( 45 'capability_type' => array( 'unmapped_meta_cap', 'unmapped_meta_caps' ), 46 'map_meta_cap' => false, 47 ) ); 48 49 register_post_type( 'no_admin_caps', array( 50 'capability_type' => array( 'no_admin_cap', 'no_admin_caps' ), 51 'map_meta_cap' => false, 52 ) ); 43 register_post_type( 44 'mapped_meta_caps', 45 array( 46 'capability_type' => array( 'mapped_meta_cap', 'mapped_meta_caps' ), 47 'map_meta_cap' => true, 48 ) 49 ); 50 51 register_post_type( 52 'unmapped_meta_caps', 53 array( 54 'capability_type' => array( 'unmapped_meta_cap', 'unmapped_meta_caps' ), 55 'map_meta_cap' => false, 56 ) 57 ); 58 59 register_post_type( 60 'no_admin_caps', 61 array( 62 'capability_type' => array( 'no_admin_cap', 'no_admin_caps' ), 63 'map_meta_cap' => false, 64 ) 65 ); 53 66 } 54 67 … … 180 193 wp_set_current_user( self::$user_ids['contributor'] ); 181 194 182 $post_id = $this->factory()->post->create( array( 183 'post_title' => 'Jefferson claim: nice to have Washington on your side.', 184 'post_content' => "I’m in the cabinet. I am complicit in watching him grabbin’ at power and kiss it.\n\nIf Washington isn’t gon’ listen to disciplined dissidents, this is the difference: this kid is out!", 185 'post_type' => $post_type, 186 'post_name' => 'new-washington', 187 'post_status' => 'pending', 188 ) ); 195 $post_id = $this->factory()->post->create( 196 array( 197 'post_title' => 'Jefferson claim: nice to have Washington on your side.', 198 'post_content' => "I’m in the cabinet. I am complicit in watching him grabbin’ at power and kiss it.\n\nIf Washington isn’t gon’ listen to disciplined dissidents, this is the difference: this kid is out!", 199 'post_type' => $post_type, 200 'post_name' => 'new-washington', 201 'post_status' => 'pending', 202 ) 203 ); 189 204 190 205 $expected = ''; 191 $actual = get_post_field( 'post_name', $post_id );206 $actual = get_post_field( 'post_name', $post_id ); 192 207 193 208 $this->assertSame( $expected, $actual ); 194 209 195 210 // Now update the post. 196 wp_update_post( array( 197 'ID' => $post_id, 198 'post_title' => 'Hamilton has Washington on side: Jefferson', 199 'post_name' => 'edited-washington', 200 ) ); 211 wp_update_post( 212 array( 213 'ID' => $post_id, 214 'post_title' => 'Hamilton has Washington on side: Jefferson', 215 'post_name' => 'edited-washington', 216 ) 217 ); 201 218 202 219 $expected = ''; 203 $actual = get_post_field( 'post_name', $post_id );220 $actual = get_post_field( 'post_name', $post_id ); 204 221 205 222 $this->assertSame( $expected, $actual ); … … 215 232 wp_set_current_user( self::$user_ids['administrator'] ); 216 233 217 $post_id = $this->factory()->post->create( array( 218 'post_title' => 'What is the Conner Project?', 219 'post_content' => "Evan Hansen’s last link to his friend Conner is a signature on his broken arm.", 220 'post_type' => $post_type, 221 'post_name' => 'dear-evan-hansen-explainer', 222 'post_status' => 'pending', 223 ) ); 234 $post_id = $this->factory()->post->create( 235 array( 236 'post_title' => 'What is the Conner Project?', 237 'post_content' => 'Evan Hansen’s last link to his friend Conner is a signature on his broken arm.', 238 'post_type' => $post_type, 239 'post_name' => 'dear-evan-hansen-explainer', 240 'post_status' => 'pending', 241 ) 242 ); 224 243 225 244 $expected = 'dear-evan-hansen-explainer'; 226 $actual = get_post_field( 'post_name', $post_id );245 $actual = get_post_field( 'post_name', $post_id ); 227 246 228 247 $this->assertSame( $expected, $actual ); 229 248 230 249 // Now update the post. 231 wp_update_post( array( 232 'ID' => $post_id, 233 'post_title' => 'Conner Project to close', 234 'post_name' => 'dear-evan-hansen-spoiler', 235 ) ); 250 wp_update_post( 251 array( 252 'ID' => $post_id, 253 'post_title' => 'Conner Project to close', 254 'post_name' => 'dear-evan-hansen-spoiler', 255 ) 256 ); 236 257 237 258 $expected = 'dear-evan-hansen-spoiler'; 238 $actual = get_post_field( 'post_name', $post_id );259 $actual = get_post_field( 'post_name', $post_id ); 239 260 240 261 $this->assertSame( $expected, $actual ); … … 252 273 wp_set_current_user( self::$user_ids['administrator'] ); 253 274 254 $post_id = $this->factory()->post->create( array( 255 'post_title' => 'Everything is legal in New Jersey', 256 'post_content' => 'Shortly before his death, Philip Hamilton was heard to claim everything was legal in the garden state.', 257 'post_type' => 'no_admin_caps', 258 'post_name' => 'yet-another-duel', 259 'post_status' => 'pending', 260 ) ); 275 $post_id = $this->factory()->post->create( 276 array( 277 'post_title' => 'Everything is legal in New Jersey', 278 'post_content' => 'Shortly before his death, Philip Hamilton was heard to claim everything was legal in the garden state.', 279 'post_type' => 'no_admin_caps', 280 'post_name' => 'yet-another-duel', 281 'post_status' => 'pending', 282 ) 283 ); 261 284 262 285 $expected = ''; 263 $actual = get_post_field( 'post_name', $post_id );286 $actual = get_post_field( 'post_name', $post_id ); 264 287 265 288 $this->assertSame( $expected, $actual ); 266 289 267 290 // Now update the post. 268 wp_update_post( array( 269 'ID' => $post_id, 270 'post_title' => 'Ten things illegal in New Jersey', 271 'post_name' => 'foreshadowing-in-nj', 272 ) ); 291 wp_update_post( 292 array( 293 'ID' => $post_id, 294 'post_title' => 'Ten things illegal in New Jersey', 295 'post_name' => 'foreshadowing-in-nj', 296 ) 297 ); 273 298 274 299 $expected = ''; 275 $actual = get_post_field( 'post_name', $post_id );300 $actual = get_post_field( 'post_name', $post_id ); 276 301 277 302 $this->assertSame( $expected, $actual );
Note: See TracChangeset
for help on using the changeset viewer.