WordPress.org

Make WordPress Core

Ticket #16373: test_page_on_front_query_var.diff

File test_page_on_front_query_var.diff, 1.1 KB (added by jondavis, 3 years ago)

test/query.php unit test for page_on_front query vars

  • tests/query.php

     
    256256                $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); 
    257257        } 
    258258 
     259        function test_page_on_front_query_var () { 
     260                $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Front', 'post_content' => 'Front Page' ) ); 
     261                update_option( 'show_on_front', 'page' ); 
     262                update_option( 'page_on_front', $page_id ); 
     263 
     264                add_filter('query_vars', create_function('$vars','$vars[] = "foo"; return $vars;')); 
     265 
     266                $this->go_to('/?foo=bard'); 
     267                $this->assertQueryTrue('is_page','is_singular'); 
     268 
     269                $this->assertEquals( get_query_var( 'foo' ), 'bard' ); 
     270 
     271                // Verify the expected page is queried 
     272                global $wp_query; 
     273                $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); 
     274        } 
     275 
    259276        // FIXME: no tests for these yet 
    260277        // 'about/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 
    261278        // 'about/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',