Query: Add and improve tests for query conditionals on the front page and home page.
See #37851 git-svn-id: https://develop.svn.wordpress.org/trunk@38413 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
20dae52ec9
commit
7bb34dc5d9
@ -32,6 +32,28 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
$this->assertQueryTrue( 'is_home', 'is_front_page' );
|
||||
}
|
||||
|
||||
function test_page_on_front() {
|
||||
$page_on_front = self::factory()->post->create( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
$page_for_posts = self::factory()->post->create( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
update_option( 'show_on_front', 'page' );
|
||||
update_option( 'page_on_front', $page_on_front );
|
||||
update_option( 'page_for_posts', $page_for_posts );
|
||||
|
||||
$this->go_to( '/' );
|
||||
$this->assertQueryTrue( 'is_front_page', 'is_page', 'is_singular' );
|
||||
|
||||
$this->go_to( get_permalink( $page_for_posts ) );
|
||||
$this->assertQueryTrue( 'is_home', 'is_posts_page' );
|
||||
|
||||
update_option( 'show_on_front', 'posts' );
|
||||
delete_option( 'page_on_front' );
|
||||
delete_option( 'page_for_posts' );
|
||||
}
|
||||
|
||||
function test_404() {
|
||||
$this->go_to('/'.rand_str());
|
||||
$this->assertQueryTrue('is_404');
|
||||
@ -198,7 +220,6 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
$this->assertEquals( $page_id, $wp_query->get_queried_object()->ID );
|
||||
}
|
||||
|
||||
// FIXME: what is this for?
|
||||
// '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]'
|
||||
function test_pagination_of_posts_page() {
|
||||
$page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
|
||||
@ -212,6 +233,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// make sure the correct page was fetched
|
||||
global $wp_query;
|
||||
$this->assertEquals( $page_id, $wp_query->get_queried_object()->ID );
|
||||
|
||||
update_option( 'show_on_front', 'posts' );
|
||||
delete_option( 'page_for_posts' );
|
||||
}
|
||||
|
||||
// FIXME: no tests for these yet
|
||||
@ -329,6 +353,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
|
||||
function test_category_feed() {
|
||||
self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
|
||||
|
||||
// check the long form
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
foreach ($types as $type) {
|
||||
|
Loading…
Reference in New Issue
Block a user