Changeset 34810
- Timestamp:
- 10/03/2015 08:54:11 PM (9 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r34807 r34810 51 51 $this->reset_taxonomies(); 52 52 $this->reset_post_statuses(); 53 $this-> reset_permalinks();53 $this->set_permalink_structure(); 54 54 } 55 55 … … 654 654 * 655 655 * @global WP_Rewrite $wp_rewrite 656 */ 657 public function reset_permalinks() { 656 * 657 * @param string $structure Optional. Permalink structure to set. Default empty. 658 */ 659 public function set_permalink_structure( $structure = '' ) { 658 660 global $wp_rewrite; 659 661 660 662 $wp_rewrite->init(); 661 $wp_rewrite->set_permalink_structure( '');663 $wp_rewrite->set_permalink_structure( $structure ); 662 664 $wp_rewrite->flush_rules(); 663 665 } -
trunk/tests/phpunit/tests/admin/includesPost.php
r34802 r34810 252 252 */ 253 253 public function test_get_sample_permalink_should_return_pretty_permalink_for_posts_with_post_status_future() { 254 global $wp_rewrite;255 256 254 $permalink_structure = '%postname%'; 257 $wp_rewrite->set_permalink_structure( "/$permalink_structure/" ); 258 flush_rewrite_rules(); 255 $this->set_permalink_structure( "/$permalink_structure/" ); 259 256 260 257 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); … … 286 283 */ 287 284 public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_link_when_pretty_permalinks_are_enabled() { 288 global $wp_rewrite; 289 $permalink_structure = '%postname%'; 290 $wp_rewrite->set_permalink_structure( "/$permalink_structure/" ); 291 flush_rewrite_rules(); 285 $this->set_permalink_structure( '/%postname%/' ); 292 286 293 287 wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); … … 306 300 */ 307 301 public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_link_when_changing_slug() { 308 global $wp_rewrite; 309 $permalink_structure = '%postname%'; 310 $wp_rewrite->set_permalink_structure( "/$permalink_structure/" ); 311 flush_rewrite_rules(); 302 $this->set_permalink_structure( '/%postname%/' ); 312 303 313 304 wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); … … 347 338 */ 348 339 public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_year_archives() { 349 global $wp_rewrite; 350 $wp_rewrite->init(); 351 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 352 $wp_rewrite->flush_rules(); 340 $this->set_permalink_structure( '/%postname%/' ); 353 341 354 342 $p = $this->factory->post->create( array( … … 364 352 */ 365 353 public function test_get_sample_permalink_should_allow_yearlike_slugs_if_permastruct_does_not_cause_an_archive_conflict() { 366 global $wp_rewrite; 367 $wp_rewrite->init(); 368 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 369 $wp_rewrite->flush_rules(); 354 $this->set_permalink_structure( '/%year%/%postname%/' ); 370 355 371 356 $p = $this->factory->post->create( array( … … 381 366 */ 382 367 public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_month_archives() { 383 global $wp_rewrite; 384 $wp_rewrite->init(); 385 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 386 $wp_rewrite->flush_rules(); 368 $this->set_permalink_structure( '/%year%/%postname%/' ); 387 369 388 370 $p = $this->factory->post->create( array( … … 398 380 */ 399 381 public function test_get_sample_permalink_should_ignore_potential_month_conflicts_for_invalid_monthnum() { 400 global $wp_rewrite; 401 $wp_rewrite->init(); 402 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 403 $wp_rewrite->flush_rules(); 382 $this->set_permalink_structure( '/%year%/%postname%/' ); 404 383 405 384 $p = $this->factory->post->create( array( … … 415 394 */ 416 395 public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_day_archives() { 417 global $wp_rewrite; 418 $wp_rewrite->init(); 419 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 420 $wp_rewrite->flush_rules(); 396 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 421 397 422 398 $p = $this->factory->post->create( array( … … 432 408 */ 433 409 public function test_get_sample_permalink_should_iterate_slug_suffix_when_a_date_conflict_is_found() { 434 global $wp_rewrite; 435 $wp_rewrite->init(); 436 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 437 $wp_rewrite->flush_rules(); 410 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 438 411 439 412 $this->factory->post->create( array( … … 453 426 */ 454 427 public function test_get_sample_permalink_should_ignore_potential_day_conflicts_for_invalid_day() { 455 global $wp_rewrite; 456 $wp_rewrite->init(); 457 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 458 $wp_rewrite->flush_rules(); 428 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 459 429 460 430 $p = $this->factory->post->create( array( … … 470 440 */ 471 441 public function test_get_sample_permalink_should_allow_daylike_slugs_if_permastruct_does_not_cause_an_archive_conflict() { 472 global $wp_rewrite; 473 $wp_rewrite->init(); 474 $wp_rewrite->set_permalink_structure( '/%year%/%month%/%day%/%postname%/' ); 475 $wp_rewrite->flush_rules(); 442 $this->set_permalink_structure( '/%year%/%month%/%day%/%postname%/' ); 476 443 477 444 $p = $this->factory->post->create( array( -
trunk/tests/phpunit/tests/link.php
r34802 r34810 21 21 $old_req_uri = $_SERVER['REQUEST_URI']; 22 22 23 global $wp_rewrite; 24 $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 25 $wp_rewrite->flush_rules(); 23 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 26 24 27 25 add_filter( 'home_url', array( $this, '_get_pagenum_link_cb' ) ); … … 36 34 37 35 function test_wp_get_shortlink() { 38 global $wp_rewrite;39 40 36 $post_id = $this->factory->post->create(); 41 37 $post_id2 = $this->factory->post->create(); … … 68 64 $this->assertEquals( '', wp_get_shortlink() ); 69 65 70 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 71 $wp_rewrite->flush_rules(); 66 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 72 67 73 68 // With a permalink structure set, get_permalink() will no longer match. … … 89 84 $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); 90 85 91 global $wp_rewrite; 92 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 93 $wp_rewrite->flush_rules(); 86 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 94 87 95 88 $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); … … 106 99 $this->assertEquals( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); 107 100 108 global $wp_rewrite; 109 $wp_rewrite->permalink_structure = ''; 110 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 111 $wp_rewrite->flush_rules(); 101 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 112 102 113 103 $this->assertEquals( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); … … 397 387 */ 398 388 public function test_unattached_attachment_has_a_pretty_permalink() { 399 global $wp_rewrite; 400 $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 401 $wp_rewrite->flush_rules(); 389 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 402 390 403 391 $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( … … 417 405 */ 418 406 public function test_attachment_attached_to_non_existent_post_type_has_a_pretty_permalink() { 419 global $wp_rewrite, $wp_post_types; 420 $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 407 global $wp_post_types; 408 409 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 421 410 422 411 register_post_type( 'not_a_post_type', array( 'public' => true ) ); 423 412 424 $wp_rewrite->flush_rules();413 flush_rewrite_rules(); 425 414 426 415 $post_id = $this->factory->post->create( array( 'post_type' => 'not_a_post_type' ) ); -
trunk/tests/phpunit/tests/link/getPostCommentsFeedLink.php
r34802 r34810 18 18 19 19 public function test_post_pretty_link() { 20 global $wp_rewrite; 21 $wp_rewrite->init(); 22 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 23 $wp_rewrite->flush_rules(); 20 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 24 21 25 22 $post_id = $this->factory->post->create(); … … 48 45 49 46 public function test_attachment_pretty_link() { 50 global $wp_rewrite; 51 $wp_rewrite->init(); 52 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 53 $wp_rewrite->flush_rules(); 47 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 54 48 55 49 $post_id = $this->factory->post->create( array( … … 71 65 72 66 public function test_attachment_no_name_pretty_link() { 73 global $wp_rewrite; 74 $wp_rewrite->init(); 75 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 76 $wp_rewrite->flush_rules(); 67 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 77 68 78 69 $post_id = $this->factory->post->create(); … … 104 95 105 96 public function test_unattached_pretty_link() { 106 global $wp_rewrite; 107 $wp_rewrite->init(); 108 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 109 $wp_rewrite->flush_rules(); 97 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 110 98 111 99 $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( -
trunk/tests/phpunit/tests/post.php
r34802 r34810 416 416 */ 417 417 public function test_wp_insert_post_should_not_allow_a_bare_numeric_slug_that_might_conflict_with_a_date_archive_when_generating_from_an_empty_post_title() { 418 global $wp_rewrite; 419 $wp_rewrite->init(); 420 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 421 $wp_rewrite->flush_rules(); 418 $this->set_permalink_structure( '/%postname%/' ); 422 419 423 420 $p = wp_insert_post( array( … … 430 427 $post = get_post( $p ); 431 428 432 $this-> reset_permalinks();429 $this->set_permalink_structure(); 433 430 434 431 $this->assertEquals( "$p-2", $post->post_name ); … … 506 503 // might only fail if the post ID is greater than four characters 507 504 508 global $wp_rewrite; 509 $wp_rewrite->init(); 510 $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 511 $wp_rewrite->flush_rules(); 505 $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 512 506 513 507 $post = array( -
trunk/tests/phpunit/tests/post/wpUniquePostSlug.php
r34802 r34810 170 170 */ 171 171 public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_be_suffixed() { 172 global $wp_rewrite; 173 $wp_rewrite->init(); 174 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 175 $wp_rewrite->flush_rules(); 172 $this->set_permalink_structure( '/%postname%/' ); 176 173 177 174 $p = $this->factory->post->create( array( … … 188 185 */ 189 186 public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_not_be_suffixed_for_already_published_posts() { 190 global $wp_rewrite; 191 $wp_rewrite->init(); 192 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 193 $wp_rewrite->flush_rules(); 187 $this->set_permalink_structure( '/%postname%/' ); 194 188 195 189 $p = $this->factory->post->create( array( … … 207 201 */ 208 202 public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_year_archives() { 209 global $wp_rewrite; 210 $wp_rewrite->init(); 211 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 212 $wp_rewrite->flush_rules(); 203 $this->set_permalink_structure( '/%year%/%postname%/' ); 213 204 214 205 $p = $this->factory->post->create( array( … … 225 216 */ 226 217 public function test_slugs_resulting_in_permalinks_that_resemble_month_archives_should_be_suffixed() { 227 global $wp_rewrite; 228 $wp_rewrite->init(); 229 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 230 $wp_rewrite->flush_rules(); 218 $this->set_permalink_structure( '/%year%/%postname%/' ); 231 219 232 220 $p = $this->factory->post->create( array( … … 243 231 */ 244 232 public function test_monthlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_month_archives() { 245 global $wp_rewrite; 246 $wp_rewrite->init(); 247 $wp_rewrite->set_permalink_structure( '/%year%/foo/%postname%/' ); 248 $wp_rewrite->flush_rules(); 233 $this->set_permalink_structure( '/%year%/foo/%postname%/' ); 249 234 250 235 $p = $this->factory->post->create( array( … … 261 246 */ 262 247 public function test_monthlike_slugs_should_not_be_suffixed_for_invalid_month_numbers() { 263 global $wp_rewrite; 264 $wp_rewrite->init(); 265 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 266 $wp_rewrite->flush_rules(); 248 $this->set_permalink_structure( '/%year%/%postname%/' ); 267 249 268 250 $p = $this->factory->post->create( array( … … 279 261 */ 280 262 public function test_slugs_resulting_in_permalinks_that_resemble_day_archives_should_be_suffixed() { 281 global $wp_rewrite; 282 $wp_rewrite->init(); 283 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 284 $wp_rewrite->flush_rules(); 263 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 285 264 286 265 $p = $this->factory->post->create( array( … … 297 276 */ 298 277 public function test_daylike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_day_archives() { 299 global $wp_rewrite; 300 $wp_rewrite->init(); 301 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 302 $wp_rewrite->flush_rules(); 278 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 303 279 304 280 $p = $this->factory->post->create( array( … … 315 291 */ 316 292 public function test_daylike_slugs_should_not_be_suffixed_for_invalid_day_numbers() { 317 global $wp_rewrite; 318 $wp_rewrite->init(); 319 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 320 $wp_rewrite->flush_rules(); 293 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 321 294 322 295 $p = $this->factory->post->create( array( -
trunk/tests/phpunit/tests/query.php
r34697 r34810 4 4 5 5 function setUp() { 6 global $wp_rewrite;7 6 parent::setUp(); 8 7 9 $wp_rewrite->init();10 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );11 12 8 create_initial_taxonomies(); 13 14 $wp_rewrite->flush_rules(); 9 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 15 10 } 16 11 -
trunk/tests/phpunit/tests/query/conditionals.php
r31754 r34810 23 23 update_option( 'posts_per_page', 5 ); 24 24 25 global $wp_rewrite;26 27 $wp_rewrite->init();28 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );29 30 25 create_initial_taxonomies(); 31 26 32 $ wp_rewrite->flush_rules();27 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 33 28 } 34 29 -
trunk/tests/phpunit/tests/query/isTerm.php
r31622 r34810 24 24 25 25 function setUp() { 26 global $wp_rewrite;27 26 parent::setUp(); 28 27 … … 32 31 $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; 33 32 34 $wp_rewrite->init(); 35 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 33 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 36 34 37 35 create_initial_taxonomies(); 38 36 register_taxonomy( 'testtax', 'post', array( 'public' => true ) ); 39 37 40 $wp_rewrite->flush_rules();38 flush_rewrite_rules(); 41 39 42 40 $this->tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) ); -
trunk/tests/phpunit/tests/query/verboseRewriteRules.php
r33250 r34810 9 9 class Tests_Query_VerbosePageRules extends Tests_Query_Conditionals { 10 10 function setUp() { 11 global $wp_rewrite;12 13 11 parent::setUp(); 14 15 $wp_rewrite->init();16 $wp_rewrite->set_permalink_structure( '/%category%/%year%/%postname%/' );17 12 18 13 create_initial_taxonomies(); 19 14 20 $ wp_rewrite->flush_rules();15 $this->set_permalink_structure( '/%category%/%year%/%postname%/' ); 21 16 } 22 17 } -
trunk/tests/phpunit/tests/rewrite.php
r34708 r34810 10 10 11 11 function setUp() { 12 global $wp_rewrite;13 12 parent::setUp(); 14 13 15 // Need rewrite rules in place to use url_to_postid16 $wp_rewrite->init();17 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );18 19 14 create_initial_taxonomies(); 20 15 21 $ wp_rewrite->flush_rules();16 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 22 17 23 18 $this->home_url = get_option( 'home' ); -
trunk/tests/phpunit/tests/rewrite/numericSlugs.php
r34802 r34810 21 21 22 22 public function test_go_to_year_segment_collision_without_title() { 23 global $wp_rewrite, $wpdb; 24 $wp_rewrite->init(); 25 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 26 $wp_rewrite->flush_rules(); 23 global $wpdb; 24 $this->set_permalink_structure( '/%postname%/' ); 27 25 28 26 $id = $this->factory->post->create( array( … … 51 49 52 50 public function test_url_to_postid_year_segment_collision_without_title() { 53 global $wp_rewrite, $wpdb; 54 $wp_rewrite->init(); 55 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 56 $wp_rewrite->flush_rules(); 51 global $wpdb; 52 $this->set_permalink_structure( '/%postname%/' ); 57 53 58 54 $id = $this->factory->post->create( array( … … 79 75 80 76 public function test_go_to_year_segment_collision_with_title() { 81 global $wp_rewrite; 82 $wp_rewrite->init(); 83 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 84 $wp_rewrite->flush_rules(); 77 $this->set_permalink_structure( '/%postname%/' ); 85 78 86 79 $id = $this->factory->post->create( array( … … 98 91 99 92 public function test_url_to_postid_year_segment_collision_with_title() { 100 global $wp_rewrite; 101 $wp_rewrite->init(); 102 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 103 $wp_rewrite->flush_rules(); 93 $this->set_permalink_structure( '/%postname%/' ); 104 94 105 95 $id = $this->factory->post->create( array( … … 115 105 116 106 public function test_go_to_month_segment_collision_without_title() { 117 global $wp_rewrite; 118 $wp_rewrite->init(); 119 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 120 $wp_rewrite->flush_rules(); 107 $this->set_permalink_structure( '/%year%/%postname%/' ); 121 108 122 109 $id = $this->factory->post->create( array( … … 135 122 136 123 public function test_url_to_postid_month_segment_collision_without_title() { 137 global $wp_rewrite; 138 $wp_rewrite->init(); 139 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 140 $wp_rewrite->flush_rules(); 124 $this->set_permalink_structure( '/%year%/%postname%/' ); 141 125 142 126 $id = $this->factory->post->create( array( … … 153 137 154 138 public function test_go_to_month_segment_collision_without_title_no_leading_zero() { 155 global $wp_rewrite; 156 $wp_rewrite->init(); 157 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 158 $wp_rewrite->flush_rules(); 139 $this->set_permalink_structure( '/%year%/%postname%/' ); 159 140 160 141 $id = $this->factory->post->create( array( … … 173 154 174 155 public function test_url_to_postid_month_segment_collision_without_title_no_leading_zero() { 175 global $wp_rewrite; 176 $wp_rewrite->init(); 177 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 178 $wp_rewrite->flush_rules(); 156 $this->set_permalink_structure( '/%year%/%postname%/' ); 179 157 180 158 $id = $this->factory->post->create( array( … … 191 169 192 170 public function test_go_to_month_segment_collision_with_title() { 193 global $wp_rewrite; 194 $wp_rewrite->init(); 195 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 196 $wp_rewrite->flush_rules(); 171 $this->set_permalink_structure( '/%year%/%postname%/' ); 197 172 198 173 $id = $this->factory->post->create( array( … … 210 185 211 186 public function test_url_to_postid_month_segment_collision_with_title() { 212 global $wp_rewrite; 213 $wp_rewrite->init(); 214 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 215 $wp_rewrite->flush_rules(); 187 $this->set_permalink_structure( '/%year%/%postname%/' ); 216 188 217 189 $id = $this->factory->post->create( array( … … 227 199 228 200 public function test_go_to_month_segment_collision_with_title_no_leading_zero() { 229 global $wp_rewrite; 230 $wp_rewrite->init(); 231 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 232 $wp_rewrite->flush_rules(); 201 $this->set_permalink_structure( '/%year%/%postname%/' ); 233 202 234 203 $id = $this->factory->post->create( array( … … 246 215 247 216 public function test_url_to_postid_month_segment_collision_with_title_no_leading_zero() { 248 global $wp_rewrite; 249 $wp_rewrite->init(); 250 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 251 $wp_rewrite->flush_rules(); 217 $this->set_permalink_structure( '/%year%/%postname%/' ); 252 218 253 219 $id = $this->factory->post->create( array( … … 263 229 264 230 public function test_go_to_day_segment_collision_without_title() { 265 global $wp_rewrite; 266 $wp_rewrite->init(); 267 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 268 $wp_rewrite->flush_rules(); 231 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 269 232 270 233 $id = $this->factory->post->create( array( … … 283 246 284 247 public function test_url_to_postid_day_segment_collision_without_title() { 285 global $wp_rewrite; 286 $wp_rewrite->init(); 287 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 288 $wp_rewrite->flush_rules(); 248 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 289 249 290 250 $id = $this->factory->post->create( array( … … 301 261 302 262 public function test_go_to_day_segment_collision_with_title() { 303 global $wp_rewrite; 304 $wp_rewrite->init(); 305 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 306 $wp_rewrite->flush_rules(); 263 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 307 264 308 265 $id = $this->factory->post->create( array( … … 320 277 321 278 public function test_url_to_postid_day_segment_collision_with_title() { 322 global $wp_rewrite; 323 $wp_rewrite->init(); 324 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 325 $wp_rewrite->flush_rules(); 279 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 326 280 327 281 $id = $this->factory->post->create( array( … … 337 291 338 292 public function test_numeric_slug_permalink_conflicts_should_only_be_resolved_for_the_main_query() { 339 global $wp_rewrite; 340 $wp_rewrite->init(); 341 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 342 $wp_rewrite->flush_rules(); 293 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 343 294 344 295 $id = $this->factory->post->create( array( … … 361 312 362 313 public function test_month_slug_collision_should_resolve_to_date_archive_when_year_does_not_match_post_year() { 363 global $wp_rewrite; 364 $wp_rewrite->init(); 365 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 366 $wp_rewrite->flush_rules(); 314 $this->set_permalink_structure( '/%year%/%postname%/' ); 367 315 368 316 // Make sure a post is published in 2013/02, to avoid 404s. … … 392 340 393 341 public function test_day_slug_collision_should_resolve_to_date_archive_when_monthnum_does_not_match_post_month() { 394 global $wp_rewrite; 395 $wp_rewrite->init(); 396 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 397 $wp_rewrite->flush_rules(); 342 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 398 343 399 344 // Make sure a post is published on 2015/01/01, to avoid 404s. … … 423 368 424 369 public function test_date_slug_collision_should_distinguish_valid_pagination_from_date() { 425 global $wp_rewrite; 426 $wp_rewrite->init(); 427 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 428 $wp_rewrite->flush_rules(); 370 $this->set_permalink_structure( '/%year%/%postname%/' ); 429 371 430 372 $id = $this->factory->post->create( array( … … 442 384 443 385 public function test_date_slug_collision_should_distinguish_too_high_pagination_from_date() { 444 global $wp_rewrite; 445 $wp_rewrite->init(); 446 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 447 $wp_rewrite->flush_rules(); 386 $this->set_permalink_structure( '/%year%/%postname%/' ); 448 387 449 388 $id = $this->factory->post->create( array( … … 461 400 462 401 public function test_date_slug_collision_should_not_require_pagination_query_var() { 463 global $wp_rewrite; 464 $wp_rewrite->init(); 465 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 466 $wp_rewrite->flush_rules(); 402 $this->set_permalink_structure( '/%year%/%postname%/' ); 467 403 468 404 $id = $this->factory->post->create( array( … … 481 417 482 418 public function test_date_slug_collision_should_be_ignored_when_pagination_var_is_present_but_post_does_not_have_multiple_pages() { 483 global $wp_rewrite; 484 $wp_rewrite->init(); 485 $wp_rewrite->set_permalink_structure( '/%year%/%postname%/' ); 486 $wp_rewrite->flush_rules(); 419 $this->set_permalink_structure( '/%year%/%postname%/' ); 487 420 488 421 $id = $this->factory->post->create( array( -
trunk/tests/phpunit/tests/rewrite/oldSlugRedirect.php
r34802 r34810 20 20 add_filter( 'old_slug_redirect_url', array( $this, 'filter_old_slug_redirect_url' ), 10, 1 ); 21 21 22 global $wp_rewrite;22 $this->set_permalink_structure( '/%postname%/' ); 23 23 24 $wp_rewrite->init();25 $wp_rewrite->set_permalink_structure( '/%postname%/' );26 24 add_rewrite_endpoint( 'custom-endpoint', EP_PERMALINK ); 27 25 add_rewrite_endpoint( 'second-endpoint', EP_PERMALINK, 'custom' ); 28 $wp_rewrite->flush_rules(); 26 27 flush_rewrite_rules(); 29 28 } 30 29 -
trunk/tests/phpunit/tests/term/getTermLink.php
r34802 r34810 86 86 87 87 public function test_taxonomy_permastruct_with_hierarchical_rewrite_should_put_term_ancestors_in_link() { 88 global $wp_rewrite; 89 $wp_rewrite->init(); 90 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 91 $wp_rewrite->flush_rules(); 88 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 92 89 93 90 register_taxonomy( 'wptests_tax2', 'post', array( … … 98 95 ), 99 96 ) ); 97 98 flush_rewrite_rules(); 100 99 101 100 $t1 = $this->factory->term->create( array( … … 116 115 117 116 public function test_taxonomy_permastruct_with_nonhierarchical_rewrite_should_not_put_term_ancestors_in_link() { 118 global $wp_rewrite; 119 $permalink_structure = get_option( 'permalink_structure' ); 120 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 121 $wp_rewrite->flush_rules(); 117 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 122 118 123 119 register_taxonomy( 'wptests_tax2', 'post', array( … … 128 124 ), 129 125 ) ); 126 127 flush_rewrite_rules(); 130 128 131 129 $t1 = $this->factory->term->create( array( -
trunk/tests/phpunit/tests/user/author.php
r34802 r34810 128 128 */ 129 129 public function test_get_the_author_posts_link_with_permalinks() { 130 global $wp_rewrite; 131 $wp_rewrite->init(); 132 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 133 $wp_rewrite->flush_rules(); 130 $this->set_permalink_structure( '/%postname%/' ); 134 131 135 132 $author = $this->factory->user->create_and_get( array(
Note: See TracChangeset
for help on using the changeset viewer.