| 812 | |
| 813 | function test_is_page_with_page_id_zero_and_random_page_slug() { |
| 814 | $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); |
| 815 | $this->go_to( "/?page_id=$post_id" ); |
| 816 | |
| 817 | // override post ID to 0 temporarily for testing |
| 818 | $_id = $GLOBALS['wp_query']->post->ID; |
| 819 | $GLOBALS['wp_query']->post->ID = 0; |
| 820 | |
| 821 | $post = get_queried_object(); |
| 822 | $q = $GLOBALS['wp_query']; |
| 823 | |
| 824 | $this->assertTrue( $q->is_page() ); |
| 825 | $this->assertFalse( $q->is_page( 'sample-page' ) ); |
| 826 | $this->assertFalse( $q->is_page( 'random-page-slug' ) ); |
| 827 | |
| 828 | // revert $wp_query global change |
| 829 | $GLOBALS['wp_query']->post->ID = $_id; |
| 830 | } |