| 200 | |
| 201 | /** |
| 202 | * @ticket 31389 |
| 203 | */ |
| 204 | public function test_get_page_template_slug_by_id() { |
| 205 | $page_id = $this->factory->post->create( array( |
| 206 | 'post_type' => 'page', |
| 207 | ) ); |
| 208 | |
| 209 | $this->assertEquals( get_page_template_slug($page_id), '' ); |
| 210 | |
| 211 | update_post_meta($page_id, '_wp_page_template', 'default'); |
| 212 | $this->assertEquals( get_page_template_slug($page_id), '' ); |
| 213 | |
| 214 | update_post_meta($page_id, '_wp_page_template', 'example.php'); |
| 215 | $this->assertEquals( get_page_template_slug($page_id), 'example.php' ); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @ticket 31389 |
| 220 | */ |
| 221 | public function test_get_page_template_slug_from_loop() { |
| 222 | $page_id = $this->factory->post->create( array( |
| 223 | 'post_type' => 'page', |
| 224 | ) ); |
| 225 | update_post_meta($page_id, '_wp_page_template', 'example.php'); |
| 226 | $this->go_to( get_permalink( $page_id ) ); |
| 227 | |
| 228 | $this->assertEquals( get_page_template_slug(), 'example.php' ); |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * @ticket 31389 |
| 233 | */ |
| 234 | public function test_get_page_template_slug_non_page() { |
| 235 | $post_id = $this->factory->post->create( array( |
| 236 | 'post_type' => 'post', |
| 237 | ) ); |
| 238 | |
| 239 | $this->assertFalse( get_page_template_slug($post_id) ); |
| 240 | |
| 241 | $this->go_to( get_permalink( $post_id ) ); |
| 242 | $this->assertFalse( get_page_template_slug() ); |
| 243 | } |