Make WordPress Core


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

    r34802 r34810  
    1818
    1919    public function test_post_pretty_link() {
    20         global $wp_rewrite;
    21         $wp_rewrite->init();
    22         $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    23         $wp_rewrite->flush_rules();
     20        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    2421
    2522        $post_id = $this->factory->post->create();
     
    4845
    4946    public function test_attachment_pretty_link() {
    50         global $wp_rewrite;
    51         $wp_rewrite->init();
    52         $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    53         $wp_rewrite->flush_rules();
     47        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    5448
    5549        $post_id = $this->factory->post->create( array(
     
    7165
    7266    public function test_attachment_no_name_pretty_link() {
    73         global $wp_rewrite;
    74         $wp_rewrite->init();
    75         $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    76         $wp_rewrite->flush_rules();
     67        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    7768
    7869        $post_id = $this->factory->post->create();
     
    10495
    10596    public function test_unattached_pretty_link() {
    106         global $wp_rewrite;
    107         $wp_rewrite->init();
    108         $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    109         $wp_rewrite->flush_rules();
     97        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    11098
    11199        $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
Note: See TracChangeset for help on using the changeset viewer.