From 80a817ebcc1ba23465a9977fc2ce2b26117d72a2 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 3 Jul 2014 00:49:32 +0000 Subject: [PATCH] Make sure hundreds of canonical tests don't fail in multisite every other time they are run. See #28706. git-svn-id: https://develop.svn.wordpress.org/trunk@28964 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/canonical.php | 10 +++++++--- tests/phpunit/tests/link.php | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php index af073595c4..a673cc7566 100644 --- a/tests/phpunit/tests/canonical.php +++ b/tests/phpunit/tests/canonical.php @@ -19,16 +19,20 @@ class Tests_Canonical extends WP_UnitTestCase { var $term_ids; function setUp() { + global $wp_rewrite; + parent::setUp(); update_option( 'page_comments', true ); update_option( 'comments_per_page', 5 ); update_option( 'posts_per_page', 5 ); - update_option( 'permalink_structure', $this->structure ); + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( $this->structure ); + create_initial_taxonomies(); - $GLOBALS['wp_rewrite']->init(); - flush_rewrite_rules(); + + $wp_rewrite->flush_rules(); $this->old_current_user = get_current_user_id(); $this->author_id = $this->factory->user->create( array( 'user_login' => 'canonical-author' ) ); diff --git a/tests/phpunit/tests/link.php b/tests/phpunit/tests/link.php index 9dd2750be9..3b363e1659 100644 --- a/tests/phpunit/tests/link.php +++ b/tests/phpunit/tests/link.php @@ -34,8 +34,9 @@ class Tests_Link extends WP_UnitTestCase { $post_id = $this->factory->post->create(); $post_id2 = $this->factory->post->create(); - $wp_rewrite->permalink_structure = ''; + $wp_rewrite->init(); $wp_rewrite->set_permalink_structure( '' ); + $wp_rewrite->flush_rules(); // Basic case $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) );