mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
This aims to bring some consistency to the location of post template function tests, as well as to make the tests more discoverable and easier to expand. Includes: * Adding `@covers` tags. * Renaming `get_post_parent()` and `has_post_parent()` tests to match the names of the functions. Follow-up to [28398], [31522], [34654], [34950], [50127], [50396], [54717], [54726], [55590]. See #57841. git-svn-id: https://develop.svn.wordpress.org/trunk@55591 602fd350-edb4-49c9-b593-d223f7449a82
76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group post
|
|
* @group template
|
|
*
|
|
* @covers ::get_page_template_slug
|
|
*/
|
|
class Tests_Post_GetPageTemplateSlug extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* @ticket 31389
|
|
*/
|
|
public function test_get_page_template_slug_by_id() {
|
|
$page_id = self::factory()->post->create(
|
|
array(
|
|
'post_type' => 'page',
|
|
)
|
|
);
|
|
|
|
$this->assertSame( '', get_page_template_slug( $page_id ) );
|
|
|
|
update_post_meta( $page_id, '_wp_page_template', 'default' );
|
|
$this->assertSame( '', get_page_template_slug( $page_id ) );
|
|
|
|
update_post_meta( $page_id, '_wp_page_template', 'example.php' );
|
|
$this->assertSame( 'example.php', get_page_template_slug( $page_id ) );
|
|
}
|
|
|
|
/**
|
|
* @ticket 31389
|
|
*/
|
|
public function test_get_page_template_slug_from_loop() {
|
|
$page_id = self::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->assertSame( 'example.php', get_page_template_slug() );
|
|
}
|
|
|
|
/**
|
|
* @ticket 31389
|
|
* @ticket 18375
|
|
*/
|
|
public function test_get_page_template_slug_non_page() {
|
|
$post_id = self::factory()->post->create();
|
|
|
|
$this->assertSame( '', get_page_template_slug( $post_id ) );
|
|
|
|
update_post_meta( $post_id, '_wp_page_template', 'default' );
|
|
|
|
$this->assertSame( '', get_page_template_slug( $post_id ) );
|
|
|
|
update_post_meta( $post_id, '_wp_page_template', 'example.php' );
|
|
$this->assertSame( 'example.php', get_page_template_slug( $post_id ) );
|
|
}
|
|
|
|
/**
|
|
* @ticket 18375
|
|
*/
|
|
public function test_get_page_template_slug_non_page_from_loop() {
|
|
$post_id = self::factory()->post->create();
|
|
|
|
update_post_meta( $post_id, '_wp_page_template', 'example.php' );
|
|
|
|
$this->go_to( get_permalink( $post_id ) );
|
|
|
|
$this->assertSame( 'example.php', get_page_template_slug() );
|
|
}
|
|
}
|