From 158aecc3ec7c50be50a57b195fb10a47c06156cf Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 24 Sep 2015 04:19:56 +0000 Subject: [PATCH] Feeds/Links: after [34336], use a different meat cleaver to fix Rewrite spillage across test cases. Fixes #33693. git-svn-id: https://develop.svn.wordpress.org/trunk@34477 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/link/getPostCommentsFeedLink.php | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/tests/phpunit/tests/link/getPostCommentsFeedLink.php b/tests/phpunit/tests/link/getPostCommentsFeedLink.php index cd05ae6646..ff424cbc18 100644 --- a/tests/phpunit/tests/link/getPostCommentsFeedLink.php +++ b/tests/phpunit/tests/link/getPostCommentsFeedLink.php @@ -3,30 +3,12 @@ * @group link */ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { - protected $permalink_structure; - - function setUp() { - parent::setUp(); - - $this->permalink_structure = get_option( 'permalink_structure' ); - } - - function tearDown() { - $this->remove_added_uploads(); - - parent::tearDown(); - - $this->set_permalink_structure( $this->permalink_structure ); - } - - public function set_permalink_structure( $permalink_structure ) { - global $wp_rewrite; - $wp_rewrite->set_permalink_structure( $permalink_structure ); - $wp_rewrite->flush_rules(); - } - public function test_post_link() { - $this->set_permalink_structure( '' ); + global $wp_rewrite; + $permalink_structure = get_option( 'permalink_structure' ); + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( '' ); + $wp_rewrite->flush_rules(); $post_id = $this->factory->post->create(); @@ -40,7 +22,11 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { } public function test_post_pretty_link() { - $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + global $wp_rewrite; + $permalink_structure = get_option( 'permalink_structure' ); + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + $wp_rewrite->flush_rules(); $post_id = $this->factory->post->create(); @@ -51,7 +37,10 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { } public function test_attachment_link() { - $this->set_permalink_structure( '' ); + global $wp_rewrite; + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( '' ); + $wp_rewrite->flush_rules(); $post_id = $this->factory->post->create(); $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array( @@ -69,7 +58,10 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { } public function test_attachment_pretty_link() { - $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + global $wp_rewrite; + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + $wp_rewrite->flush_rules(); $post_id = $this->factory->post->create( array( 'post_status' => 'publish' @@ -89,7 +81,10 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { } public function test_attachment_no_name_pretty_link() { - $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + global $wp_rewrite; + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + $wp_rewrite->flush_rules(); $post_id = $this->factory->post->create(); $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array( @@ -98,16 +93,16 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { ) ); $link = get_post_comments_feed_link( $attachment_id ); - $expected = add_query_arg( array( - 'feed' => get_default_feed(), - 'p' => $attachment_id - ), home_url( '/' ) ); - + $expected = get_permalink( $post_id ) . 'attachment/' . $attachment_id . '/feed/'; + $this->assertEquals( $expected, $link ); } public function test_unattached_link() { - $this->set_permalink_structure( '' ); + global $wp_rewrite; + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( '' ); + $wp_rewrite->flush_rules(); $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( 'post_mime_type' => 'image/jpeg', @@ -124,7 +119,10 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { } public function test_unattached_pretty_link() { - $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + global $wp_rewrite; + $wp_rewrite->init(); + $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + $wp_rewrite->flush_rules(); $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( 'post_mime_type' => 'image/jpeg',