@@ -251,11 +251,8 @@ function test_bulk_edit_posts_stomping() {
251251 * @ticket 30910
252252 */
253253 public function test_get_sample_permalink_should_return_pretty_permalink_for_posts_with_post_status_future () {
254- global $ wp_rewrite ;
255-
256254 $ permalink_structure = '%postname% ' ;
257- $ wp_rewrite ->set_permalink_structure ( "/ $ permalink_structure/ " );
258- flush_rewrite_rules ();
255+ $ this ->set_permalink_structure ( "/ $ permalink_structure/ " );
259256
260257 $ future_date = date ( 'Y-m-d H:i:s ' , time () + 100 );
261258 $ p = $ this ->factory ->post ->create ( array ( 'post_status ' => 'future ' , 'post_name ' => 'foo ' , 'post_date ' => $ future_date ) );
@@ -285,10 +282,7 @@ public function test_get_sample_permalink_html_should_use_default_permalink_for_
285282 * @ticket 18306
286283 */
287284 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%/ ' );
292286
293287 wp_set_current_user ( $ this ->factory ->user ->create ( array ( 'role ' => 'administrator ' ) ) );
294288
@@ -305,10 +299,7 @@ public function test_get_sample_permalink_html_should_use_pretty_permalink_for_v
305299 * @ticket 18306
306300 */
307301 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%/ ' );
312303
313304 wp_set_current_user ( $ this ->factory ->user ->create ( array ( 'role ' => 'administrator ' ) ) );
314305
@@ -346,10 +337,7 @@ public function test_get_sample_permalink_html_should_use_correct_permalink_for_
346337 * @ticket 5305
347338 */
348339 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%/ ' );
353341
354342 $ p = $ this ->factory ->post ->create ( array (
355343 'post_name ' => '2015 ' ,
@@ -363,10 +351,7 @@ public function test_get_sample_permalink_should_avoid_slugs_that_would_create_c
363351 * @ticket 5305
364352 */
365353 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%/ ' );
370355
371356 $ p = $ this ->factory ->post ->create ( array (
372357 'post_name ' => '2015 ' ,
@@ -380,10 +365,7 @@ public function test_get_sample_permalink_should_allow_yearlike_slugs_if_permast
380365 * @ticket 5305
381366 */
382367 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%/ ' );
387369
388370 $ p = $ this ->factory ->post ->create ( array (
389371 'post_name ' => '11 ' ,
@@ -397,10 +379,7 @@ public function test_get_sample_permalink_should_avoid_slugs_that_would_create_c
397379 * @ticket 5305
398380 */
399381 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%/ ' );
404383
405384 $ p = $ this ->factory ->post ->create ( array (
406385 'post_name ' => '13 ' ,
@@ -414,10 +393,7 @@ public function test_get_sample_permalink_should_ignore_potential_month_conflict
414393 * @ticket 5305
415394 */
416395 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%/ ' );
421397
422398 $ p = $ this ->factory ->post ->create ( array (
423399 'post_name ' => '30 ' ,
@@ -431,10 +407,7 @@ public function test_get_sample_permalink_should_avoid_slugs_that_would_create_c
431407 * @ticket 5305
432408 */
433409 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%/ ' );
438411
439412 $ this ->factory ->post ->create ( array (
440413 'post_name ' => '30-2 ' ,
@@ -452,10 +425,7 @@ public function test_get_sample_permalink_should_iterate_slug_suffix_when_a_date
452425 * @ticket 5305
453426 */
454427 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%/ ' );
459429
460430 $ p = $ this ->factory ->post ->create ( array (
461431 'post_name ' => '32 ' ,
@@ -469,10 +439,7 @@ public function test_get_sample_permalink_should_ignore_potential_day_conflicts_
469439 * @ticket 5305
470440 */
471441 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%/ ' );
476443
477444 $ p = $ this ->factory ->post ->create ( array (
478445 'post_name ' => '30 ' ,
0 commit comments