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/post.php

    r34802 r34810  
    416416     */
    417417    public function test_wp_insert_post_should_not_allow_a_bare_numeric_slug_that_might_conflict_with_a_date_archive_when_generating_from_an_empty_post_title() {
    418         global $wp_rewrite;
    419         $wp_rewrite->init();
    420         $wp_rewrite->set_permalink_structure( '/%postname%/' );
    421         $wp_rewrite->flush_rules();
     418        $this->set_permalink_structure( '/%postname%/' );
    422419
    423420        $p = wp_insert_post( array(
     
    430427        $post = get_post( $p );
    431428
    432         $this->reset_permalinks();
     429        $this->set_permalink_structure();
    433430
    434431        $this->assertEquals( "$p-2", $post->post_name );
     
    506503        // might only fail if the post ID is greater than four characters
    507504
    508         global $wp_rewrite;
    509         $wp_rewrite->init();
    510         $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
    511         $wp_rewrite->flush_rules();
     505        $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
    512506
    513507        $post = array(
Note: See TracChangeset for help on using the changeset viewer.