Add unit tests for `get_page_template_slug()`.

props tyxla.
fixes #31389.

git-svn-id: https://develop.svn.wordpress.org/trunk@31522 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-02-23 18:47:01 +00:00
parent ed1cc5a126
commit 0421ee26ec
1 changed files with 245 additions and 200 deletions

View File

@ -197,4 +197,49 @@ NO;
$this->assertContains( 'value="' . $p . '"', $found );
}
/**
* @ticket 31389
*/
public function test_get_page_template_slug_by_id() {
$page_id = $this->factory->post->create( array(
'post_type' => 'page',
) );
$this->assertEquals( '', get_page_template_slug( $page_id ) );
update_post_meta( $page_id, '_wp_page_template', 'default' );
$this->assertEquals( '', get_page_template_slug( $page_id ) );
update_post_meta( $page_id, '_wp_page_template', 'example.php' );
$this->assertEquals( 'example.php', get_page_template_slug( $page_id ) );
}
/**
* @ticket 31389
*/
public function test_get_page_template_slug_from_loop() {
$page_id = $this->factory->post->create( array(
'post_type' => 'page',
) );
update_post_meta( $page_id, '_wp_page_template', 'example.php' );
$this->go_to( get_permalink( $page_id ) );
$this->assertEquals( 'example.php', get_page_template_slug() );
}
/**
* @ticket 31389
*/
public function test_get_page_template_slug_non_page() {
$post_id = $this->factory->post->create( array(
'post_type' => 'post',
) );
$this->assertFalse( get_page_template_slug( $post_id ) );
$this->go_to( get_permalink( $post_id ) );
$this->assertFalse( get_page_template_slug() );
}
}