Make WordPress Core


Ignore:
Timestamp:
08/28/2016 02:01:53 AM (8 years ago)
Author:
johnbillion
Message:

Query: Add and improve tests for query conditionals on the front page and home page.

See #37851

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/conditionals.php

    r38407 r38413  
    3333    }
    3434
     35    function test_page_on_front() {
     36        $page_on_front = self::factory()->post->create( array(
     37            'post_type' => 'page',
     38        ) );
     39        $page_for_posts = self::factory()->post->create( array(
     40            'post_type' => 'page',
     41        ) );
     42        update_option( 'show_on_front', 'page' );
     43        update_option( 'page_on_front', $page_on_front );
     44        update_option( 'page_for_posts', $page_for_posts );
     45
     46        $this->go_to( '/' );
     47        $this->assertQueryTrue( 'is_front_page', 'is_page', 'is_singular' );
     48
     49        $this->go_to( get_permalink( $page_for_posts ) );
     50        $this->assertQueryTrue( 'is_home', 'is_posts_page' );
     51
     52        update_option( 'show_on_front', 'posts' );
     53        delete_option( 'page_on_front' );
     54        delete_option( 'page_for_posts' );
     55    }
     56
    3557    function test_404() {
    3658        $this->go_to('/'.rand_str());
     
    199221    }
    200222
    201     // FIXME: what is this for?
    202223    // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]'
    203224    function test_pagination_of_posts_page() {
     
    213234        global $wp_query;
    214235        $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID );
     236
     237        update_option( 'show_on_front', 'posts' );
     238        delete_option( 'page_for_posts' );
    215239    }
    216240
     
    330354    function test_category_feed() {
    331355        self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
     356
    332357        // check the long form
    333358        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
Note: See TracChangeset for help on using the changeset viewer.