From 58d7f89bf71f6e52159776667f18b8617018b0c0 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Tue, 29 Sep 2015 02:18:55 +0000 Subject: [PATCH] Tests: Flush rewrite rules between tests in an attempt to avoid permalinks pollution in `Tests_Author_Template`. See #30355. git-svn-id: https://develop.svn.wordpress.org/trunk@34678 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/template/author.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/template/author.php b/tests/phpunit/tests/template/author.php index 98fa735632..a84e8d8409 100644 --- a/tests/phpunit/tests/template/author.php +++ b/tests/phpunit/tests/template/author.php @@ -6,6 +6,25 @@ * @group template */ class Tests_Author_Template extends WP_UnitTestCase { + private $permalink_structure; + + public function setUp() { + parent::setUp(); + + global $wp_rewrite; + $this->permalink_structure = get_option( 'permalink_structure' ); + $wp_rewrite->set_permalink_structure( '' ); + $wp_rewrite->flush_rules(); + + } + + public function tearDown() { + global $wp_rewrite; + $wp_rewrite->set_permalink_structure( $this->permalink_structure ); + $wp_rewrite->flush_rules(); + + parent::tearDown(); + } /** * @ticket 30355 @@ -53,8 +72,6 @@ class Tests_Author_Template extends WP_UnitTestCase { $this->assertContains( 'Posts by Foo', $link ); $this->assertContains( '>Foo', $link ); - // Cleanup. - $wp_rewrite->set_permalink_structure( '' ); unset( $GLOBALS['authordata'] ); } }