Make WordPress Core


Ignore:
Timestamp:
10/03/2015 08:54:11 PM (9 years ago)
Author:
DrewAPicture
Message:

Tests: Permalink Structures Phase II: DRY up logic for setting permalink structures in test methods.

Renames reset_permalinks() to set_permalink_structure() (mimicking $wp_rewrite->set_permalink_structure()) and allows it to accept an optional permalink structure. In this way, we can double dip using it to both set and reset the permalink structure from anywhere.

Removes alot of duplicated code from tests.

See #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTermLink.php

    r34802 r34810  
    8686
    8787    public function test_taxonomy_permastruct_with_hierarchical_rewrite_should_put_term_ancestors_in_link() {
    88         global $wp_rewrite;
    89         $wp_rewrite->init();
    90         $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    91         $wp_rewrite->flush_rules();
     88        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    9289
    9390        register_taxonomy( 'wptests_tax2', 'post', array(
     
    9895            ),
    9996        ) );
     97
     98        flush_rewrite_rules();
    10099
    101100        $t1 = $this->factory->term->create( array(
     
    116115
    117116    public function test_taxonomy_permastruct_with_nonhierarchical_rewrite_should_not_put_term_ancestors_in_link() {
    118         global $wp_rewrite;
    119         $permalink_structure = get_option( 'permalink_structure' );
    120         $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    121         $wp_rewrite->flush_rules();
     117        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    122118
    123119        register_taxonomy( 'wptests_tax2', 'post', array(
     
    128124            ),
    129125        ) );
     126
     127        flush_rewrite_rules();
    130128
    131129        $t1 = $this->factory->term->create( array(
Note: See TracChangeset for help on using the changeset viewer.