Make WordPress Core

Changeset 28966


Ignore:
Timestamp:
07/03/2014 01:42:57 AM (12 years ago)
Author:
wonderboymusic
Message:

Setup rewrite changes in tests in a predictable fashion. Don't mix method calls with wrapper function calls.

See #28706.

Location:
trunk/tests/phpunit/tests
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/canonical.php

    r28964 r28966  
    8585
    8686        function tearDown() {
     87                global $wp_rewrite;
    8788                parent::tearDown();
    8889                wp_set_current_user( $this->old_current_user );
    8990
    90                 $GLOBALS['wp_rewrite']->init();
     91                $wp_rewrite->init();
    9192        }
    9293
  • trunk/tests/phpunit/tests/canonical/pageOnFront.php

    r25002 r28966  
    1616                update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
    1717                $wp_rewrite->init();
    18                 flush_rewrite_rules();
     18                $wp_rewrite->flush_rules();
     19        }
     20
     21        function tearDown() {
     22                global $wp_rewrite;
     23                parent::tearDown();
     24                $wp_rewrite->init();
    1925        }
    2026
  • trunk/tests/phpunit/tests/link.php

    r28964 r28966  
    44 */
    55class Tests_Link extends WP_UnitTestCase {
     6
     7        function tearDown() {
     8                global $wp_rewrite;
     9                parent::tearDown();
     10                $wp_rewrite->init();
     11        }
    612
    713        function _get_pagenum_link_cb( $url ) {
     
    6672                $this->assertEquals( '', wp_get_shortlink() );
    6773
    68                 $wp_rewrite->permalink_structure = '';
    6974                $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    7075                $wp_rewrite->flush_rules();
     
    7984                $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( 0 ) );
    8085                $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink() );
    81 
    82                 $wp_rewrite->set_permalink_structure( '' );
    83                 $wp_rewrite->flush_rules();
    8486        }
    8587
     
    9294
    9395                global $wp_rewrite;
    94                 $wp_rewrite->permalink_structure = '';
    9596                $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    9697                $wp_rewrite->flush_rules();
    9798
    9899                $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) );
    99 
    100                 $wp_rewrite->set_permalink_structure( '' );
    101                 $wp_rewrite->flush_rules();
    102100        }
    103101
     
    118116
    119117                $this->assertEquals( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) );
    120 
    121                 $wp_rewrite->set_permalink_structure( '' );
    122                 $wp_rewrite->flush_rules();
    123118        }
    124119
  • trunk/tests/phpunit/tests/query/conditionals.php

    r27187 r28966  
    2424
    2525                global $wp_rewrite;
    26                 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
     26
     27                $wp_rewrite->init();
     28                $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     29
    2730                create_initial_taxonomies();
    28                 $GLOBALS['wp_rewrite']->init();
    29                 flush_rewrite_rules();
     31
     32                $wp_rewrite->flush_rules();
    3033        }
    3134
    3235        function tearDown() {
     36                global $wp_rewrite;
    3337                parent::tearDown();
    34                 $GLOBALS['wp_rewrite']->init();
     38                $wp_rewrite->init();
    3539        }
    3640
  • trunk/tests/phpunit/tests/query/taxQuery.php

    r26875 r28966  
    2323
    2424        function setUp() {
     25                global $wp_rewrite;
    2526                parent::setUp();
    2627
    2728                set_current_screen( 'front' );
    2829
    29                 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
    30 
    3130                $GLOBALS['wp_the_query'] = new WP_Query();
    3231                $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
     32
     33                $wp_rewrite->init();
     34                $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    3335
    3436                create_initial_taxonomies();
    3537                register_taxonomy( 'testtax', 'post', array( 'public' => true ) );
    3638
    37                 $GLOBALS['wp_rewrite']->init();
    38                 flush_rewrite_rules();
     39                $wp_rewrite->flush_rules();
    3940
    4041                $this->tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) );
     
    5758
    5859        function tearDown() {
     60                global $wp_rewrite;
    5961                parent::tearDown();
    6062
    6163                _unregister_taxonomy( 'testtax' );
     64
     65                $wp_rewrite->init();
    6266
    6367                remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
  • trunk/tests/phpunit/tests/query/verboseRewriteRules.php

    r25002 r28966  
    99class Tests_Query_VerbosePageRules extends Tests_Query_Conditionals {
    1010        function setUp() {
     11                global $wp_rewrite;
     12
    1113                parent::setUp();
    12                 global $wp_rewrite;
    13                 update_option( 'permalink_structure', '/%category%/%year%/%postname%/' );
     14               
     15                $wp_rewrite->init();
     16                $wp_rewrite->set_permalink_structure( '/%category%/%year%/%postname%/' );
     17
    1418                create_initial_taxonomies();
    15                 $GLOBALS['wp_rewrite']->init();
    16                 flush_rewrite_rules();
     19
     20                $wp_rewrite->flush_rules();
    1721        }
    1822}
  • trunk/tests/phpunit/tests/rewrite.php

    r25659 r28966  
    99
    1010        function setUp() {
     11                global $wp_rewrite;
    1112                parent::setUp();
    1213
    1314                // Need rewrite rules in place to use url_to_postid
    14                 global $wp_rewrite;
    15                 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
     15                $wp_rewrite->init();
     16                $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     17
    1618                create_initial_taxonomies();
    17                 $GLOBALS['wp_rewrite']->init();
    18                 flush_rewrite_rules();
     19
     20                $wp_rewrite->flush_rules();
    1921        }
    2022
    2123        function tearDown() {
     24                global $wp_rewrite;
    2225                parent::tearDown();
    23                 $GLOBALS['wp_rewrite']->init();
     26                $wp_rewrite->init();
    2427        }
    2528
     
    3538        function test_url_to_postid_custom_post_type() {
    3639                delete_option( 'rewrite_rules' );
    37                
     40
    3841                $post_type = rand_str( 12 );
    3942                register_post_type( $post_type, array( 'public' => true ) );
    40                
     43
    4144                $id = $this->factory->post->create( array( 'post_type' => $post_type ) );
    42                 $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );             
    43                
    44                 _unregister_post_type( $post_type );           
     45                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     46
     47                _unregister_post_type( $post_type );
    4548        }
    46        
     49
    4750        function test_url_to_postid_hierarchical() {
    4851
Note: See TracChangeset for help on using the changeset viewer.