Make WordPress Core


Ignore:
Timestamp:
09/24/2015 04:19:56 AM (9 years ago)
Author:
wonderboymusic
Message:

Feeds/Links: after [34336], use a different meat cleaver to fix Rewrite spillage across test cases.

Fixes #33693.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/link/getPostCommentsFeedLink.php

    r34336 r34477  
    44 */
    55class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
    6     protected $permalink_structure;
    7 
    8     function setUp() {
    9         parent::setUp();
    10 
    11         $this->permalink_structure = get_option( 'permalink_structure' );
    12     }
    13 
    14     function tearDown() {
    15         $this->remove_added_uploads();
    16 
    17         parent::tearDown();
    18 
    19         $this->set_permalink_structure( $this->permalink_structure );
    20     }
    21 
    22     public function set_permalink_structure( $permalink_structure ) {
     6    public function test_post_link() {
    237        global $wp_rewrite;
    24         $wp_rewrite->set_permalink_structure( $permalink_structure );
     8        $permalink_structure = get_option( 'permalink_structure' );
     9        $wp_rewrite->init();
     10        $wp_rewrite->set_permalink_structure( '' );
    2511        $wp_rewrite->flush_rules();
    26     }
    27 
    28     public function test_post_link() {
    29         $this->set_permalink_structure( '' );
    3012
    3113        $post_id = $this->factory->post->create();
     
    4123
    4224    public function test_post_pretty_link() {
    43         $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     25        global $wp_rewrite;
     26        $permalink_structure = get_option( 'permalink_structure' );
     27        $wp_rewrite->init();
     28        $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     29        $wp_rewrite->flush_rules();
    4430
    4531        $post_id = $this->factory->post->create();
     
    5238
    5339    public function test_attachment_link() {
    54         $this->set_permalink_structure( '' );
     40        global $wp_rewrite;
     41        $wp_rewrite->init();
     42        $wp_rewrite->set_permalink_structure( '' );
     43        $wp_rewrite->flush_rules();
    5544
    5645        $post_id = $this->factory->post->create();
     
    7059
    7160    public function test_attachment_pretty_link() {
    72         $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     61        global $wp_rewrite;
     62        $wp_rewrite->init();
     63        $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     64        $wp_rewrite->flush_rules();
    7365
    7466        $post_id = $this->factory->post->create( array(
     
    9082
    9183    public function test_attachment_no_name_pretty_link() {
    92         $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     84        global $wp_rewrite;
     85        $wp_rewrite->init();
     86        $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     87        $wp_rewrite->flush_rules();
    9388
    9489        $post_id = $this->factory->post->create();
     
    9994
    10095        $link = get_post_comments_feed_link( $attachment_id );
    101         $expected = add_query_arg( array(
    102             'feed' => get_default_feed(),
    103             'p' => $attachment_id
    104         ), home_url( '/' ) );
    105 
     96        $expected = get_permalink( $post_id ) . 'attachment/' . $attachment_id . '/feed/';
     97       
    10698        $this->assertEquals( $expected, $link );
    10799    }
    108100
    109101    public function test_unattached_link() {
    110         $this->set_permalink_structure( '' );
     102        global $wp_rewrite;
     103        $wp_rewrite->init();
     104        $wp_rewrite->set_permalink_structure( '' );
     105        $wp_rewrite->flush_rules();
    111106
    112107        $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
     
    125120
    126121    public function test_unattached_pretty_link() {
    127         $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     122        global $wp_rewrite;
     123        $wp_rewrite->init();
     124        $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     125        $wp_rewrite->flush_rules();
    128126
    129127        $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
Note: See TracChangeset for help on using the changeset viewer.