WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/03/2015 08:54:11 PM (4 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/includes/testcase.php

    r34807 r34810  
    5151            $this->reset_taxonomies();
    5252            $this->reset_post_statuses();
    53             $this->reset_permalinks();
     53            $this->set_permalink_structure();
    5454        }
    5555
     
    654654     *
    655655     * @global WP_Rewrite $wp_rewrite
    656      */
    657     public function reset_permalinks() {
     656     *
     657     * @param string $structure Optional. Permalink structure to set. Default empty.
     658     */
     659    public function set_permalink_structure( $structure = '' ) {
    658660        global $wp_rewrite;
    659661
    660662        $wp_rewrite->init();
    661         $wp_rewrite->set_permalink_structure( '' );
     663        $wp_rewrite->set_permalink_structure( $structure );
    662664        $wp_rewrite->flush_rules();
    663665    }
Note: See TracChangeset for help on using the changeset viewer.