Changeset 35242 for trunk/tests/phpunit/tests/admin/includesPost.php
- Timestamp:
- 10/17/2015 06:02:16 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesPost.php
r35225 r35242 12 12 13 13 function test__wp_translate_postdata_cap_checks_contributor() { 14 $contributor_id = self:: $factory->user->create( array( 'role' => 'contributor' ) );15 $editor_id = self:: $factory->user->create( array( 'role' => 'editor' ) );14 $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); 15 $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 16 16 17 17 wp_set_current_user( $contributor_id ); … … 52 52 // Edit Draft Post for another user 53 53 $_post_data = array(); 54 $_post_data['post_ID'] = self:: $factory->post->create( array( 'post_author' => $editor_id ) );54 $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $editor_id ) ); 55 55 $_post_data['post_author'] = $editor_id; 56 56 $_post_data['post_type'] = 'post'; … … 65 65 66 66 function test__wp_translate_postdata_cap_checks_editor() { 67 $contributor_id = self:: $factory->user->create( array( 'role' => 'contributor' ) );68 $editor_id = self:: $factory->user->create( array( 'role' => 'editor' ) );67 $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); 68 $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 69 69 70 70 wp_set_current_user( $editor_id ); … … 105 105 // Edit Draft Post for another user 106 106 $_post_data = array(); 107 $_post_data['post_ID'] = self:: $factory->post->create( array( 'post_author' => $contributor_id ) );107 $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $contributor_id ) ); 108 108 $_post_data['post_author'] = $contributor_id; 109 109 $_post_data['post_type'] = 'post'; … … 123 123 */ 124 124 function test_edit_post_auto_draft() { 125 $user_id = self:: $factory->user->create( array( 'role' => 'editor' ) );125 $user_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 126 126 wp_set_current_user( $user_id ); 127 $post = self:: $factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) );127 $post = self::factory()->post->create_and_get( array( 'post_status' => 'auto-draft' ) ); 128 128 $this->assertEquals( 'auto-draft', $post->post_status ); 129 129 $post_data = array( … … 141 141 */ 142 142 public function test_edit_post_should_parse_tax_input_by_name_rather_than_slug_for_nonhierarchical_taxonomies() { 143 $u = self:: $factory->user->create( array( 'role' => 'editor' ) );143 $u = self::factory()->user->create( array( 'role' => 'editor' ) ); 144 144 wp_set_current_user( $u ); 145 145 146 146 register_taxonomy( 'wptests_tax', array( 'post' ) ); 147 $t1 = self:: $factory->term->create( array(147 $t1 = self::factory()->term->create( array( 148 148 'taxonomy' => 'wptests_tax', 149 149 'name' => 'foo', 150 150 'slug' => 'bar', 151 151 ) ); 152 $t2 = self:: $factory->term->create( array(152 $t2 = self::factory()->term->create( array( 153 153 'taxonomy' => 'wptests_tax', 154 154 'name' => 'bar', … … 156 156 ) ); 157 157 158 $p = self:: $factory->post->create();158 $p = self::factory()->post->create(); 159 159 160 160 $post_data = array( … … 180 180 */ 181 181 public function test_edit_post_should_not_create_terms_for_an_empty_tag_input_field() { 182 $u = self:: $factory->user->create( array( 'role' => 'editor' ) );182 $u = self::factory()->user->create( array( 'role' => 'editor' ) ); 183 183 wp_set_current_user( $u ); 184 184 185 185 register_taxonomy( 'wptests_tax', array( 'post' ) ); 186 $t1 = self:: $factory->term->create( array(186 $t1 = self::factory()->term->create( array( 187 187 'taxonomy' => 'wptests_tax', 188 188 'name' => 'foo', … … 190 190 ) ); 191 191 192 $p = self:: $factory->post->create();192 $p = self::factory()->post->create(); 193 193 194 194 $post_data = array( … … 210 210 */ 211 211 function test_bulk_edit_posts_stomping() { 212 $admin = self:: $factory->user->create( array( 'role' => 'administrator' ) );213 $users = self:: $factory->user->create_many( 2, array( 'role' => 'author' ) );212 $admin = self::factory()->user->create( array( 'role' => 'administrator' ) ); 213 $users = self::factory()->user->create_many( 2, array( 'role' => 'author' ) ); 214 214 wp_set_current_user( $admin ); 215 215 216 $post1 = self:: $factory->post->create( array(216 $post1 = self::factory()->post->create( array( 217 217 'post_author' => $users[0], 218 218 'comment_status' => 'open', … … 221 221 ) ); 222 222 223 $post2 = self:: $factory->post->create( array(223 $post2 = self::factory()->post->create( array( 224 224 'post_author' => $users[1], 225 225 'comment_status' => 'closed', … … 256 256 257 257 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 258 $p = self:: $factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );258 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); 259 259 260 260 $found = get_sample_permalink( $p ); … … 269 269 */ 270 270 public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_link_when_pretty_permalinks_are_disabled() { 271 wp_set_current_user( self:: $factory->user->create( array( 'role' => 'administrator' ) ) );271 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 272 272 273 273 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 274 $p = self:: $factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );274 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); 275 275 276 276 $found = get_sample_permalink_html( $p ); … … 285 285 $this->set_permalink_structure( '/%postname%/' ); 286 286 287 wp_set_current_user( self:: $factory->user->create( array( 'role' => 'administrator' ) ) );287 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 288 288 289 289 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 290 $p = self:: $factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );290 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); 291 291 292 292 $found = get_sample_permalink_html( $p ); … … 302 302 $this->set_permalink_structure( '/%postname%/' ); 303 303 304 wp_set_current_user( self:: $factory->user->create( array( 'role' => 'administrator' ) ) );304 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 305 305 306 306 // Published posts should use published permalink 307 $p = self:: $factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) );307 $p = self::factory()->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) ); 308 308 309 309 $found = get_sample_permalink_html( $p, null, 'new_slug' ); … … 314 314 // Scheduled posts should use published permalink 315 315 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 316 $p = self:: $factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) );316 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) ); 317 317 318 318 $found = get_sample_permalink_html( $p, null, 'new_slug' ); … … 322 322 323 323 // Draft posts should use preview link 324 $p = self:: $factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) );324 $p = self::factory()->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) ); 325 325 326 326 $found = get_sample_permalink_html( $p, null, 'new_slug' ); … … 340 340 $this->set_permalink_structure( '/%postname%/' ); 341 341 342 $p = self:: $factory->post->create( array(342 $p = self::factory()->post->create( array( 343 343 'post_name' => '2015', 344 344 ) ); … … 354 354 $this->set_permalink_structure( '/%year%/%postname%/' ); 355 355 356 $p = self:: $factory->post->create( array(356 $p = self::factory()->post->create( array( 357 357 'post_name' => '2015', 358 358 ) ); … … 368 368 $this->set_permalink_structure( '/%year%/%postname%/' ); 369 369 370 $p = self:: $factory->post->create( array(370 $p = self::factory()->post->create( array( 371 371 'post_name' => '11', 372 372 ) ); … … 382 382 $this->set_permalink_structure( '/%year%/%postname%/' ); 383 383 384 $p = self:: $factory->post->create( array(384 $p = self::factory()->post->create( array( 385 385 'post_name' => '13', 386 386 ) ); … … 396 396 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 397 397 398 $p = self:: $factory->post->create( array(398 $p = self::factory()->post->create( array( 399 399 'post_name' => '30', 400 400 ) ); … … 410 410 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 411 411 412 self:: $factory->post->create( array(412 self::factory()->post->create( array( 413 413 'post_name' => '30-2', 414 414 ) ); 415 415 416 $p = self:: $factory->post->create( array(416 $p = self::factory()->post->create( array( 417 417 'post_name' => '30', 418 418 ) ); … … 428 428 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 429 429 430 $p = self:: $factory->post->create( array(430 $p = self::factory()->post->create( array( 431 431 'post_name' => '32', 432 432 ) ); … … 442 442 $this->set_permalink_structure( '/%year%/%month%/%day%/%postname%/' ); 443 443 444 $p = self:: $factory->post->create( array(444 $p = self::factory()->post->create( array( 445 445 'post_name' => '30', 446 446 ) ); … … 451 451 452 452 public function test_post_exists_should_match_title() { 453 $p = self:: $factory->post->create( array(453 $p = self::factory()->post->create( array( 454 454 'post_title' => 'Foo Bar', 455 455 ) ); … … 459 459 460 460 public function test_post_exists_should_not_match_nonexistent_title() { 461 $p = self:: $factory->post->create( array(461 $p = self::factory()->post->create( array( 462 462 'post_title' => 'Foo Bar', 463 463 ) ); … … 469 469 $title = 'Foo Bar'; 470 470 $content = 'Foo Bar Baz'; 471 $p = self:: $factory->post->create( array(471 $p = self::factory()->post->create( array( 472 472 'post_title' => $title, 473 473 'post_content' => $content, … … 480 480 $title = 'Foo Bar'; 481 481 $content = 'Foo Bar Baz'; 482 $p = self:: $factory->post->create( array(482 $p = self::factory()->post->create( array( 483 483 'post_title' => $title, 484 484 'post_content' => $content . ' Quz', … … 491 491 $title = 'Foo Bar'; 492 492 $date = '2014-05-08 12:00:00'; 493 $p = self:: $factory->post->create( array(493 $p = self::factory()->post->create( array( 494 494 'post_title' => $title, 495 495 'post_date' => $date, … … 502 502 $title = 'Foo Bar'; 503 503 $date = '2014-05-08 12:00:00'; 504 $p = self:: $factory->post->create( array(504 $p = self::factory()->post->create( array( 505 505 'post_title' => $title, 506 506 'post_date' => '2015-10-10 00:00:00', … … 514 514 $content = 'Foo Bar Baz'; 515 515 $date = '2014-05-08 12:00:00'; 516 $p = self:: $factory->post->create( array(516 $p = self::factory()->post->create( array( 517 517 'post_title' => $title, 518 518 'post_content' => $content,
Note: See TracChangeset
for help on using the changeset viewer.