Make WordPress Core


Ignore:
Timestamp:
07/03/2014 01:42:57 AM (10 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.