WordPress.org

Make WordPress Core

Changeset 995 in tests


Ignore:
Timestamp:
08/29/12 13:38:03 (20 months ago)
Author:
ryan
Message:

Tests for WP_Post->page_template. see #WP21309

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/post/objects.php

    r993 r995  
    125125    } 
    126126 
     127    function test_get_page_template_property() { 
     128        $post_id = $this->factory->post->create(); 
     129        $post = get_post( $post_id ); 
     130 
     131        $this->assertInternalType( 'string', $post->page_template ); 
     132        $this->assertEmpty( $post->tags_input ); 
     133        $template = get_post_meta( $post->ID, '_wp_page_template', true ); 
     134        $this->assertEquals( $template, $post->page_template ); 
     135        update_post_meta( $post_id, '_wp_page_template', 'foo.php' ); 
     136        $template = get_post_meta( $post->ID, '_wp_page_template', true ); 
     137        $this->assertEquals( 'foo.php', $template ); 
     138        // The post is not a page so the template is still empty 
     139        $this->assertEquals( '', $post->page_template ); 
     140 
     141        // Now the post is a page and should retrieve the template 
     142        wp_update_post( array( 'ID' => $post->ID, 'post_type' => 'page' ) ); 
     143        $post = get_post( $post_id ); 
     144        $this->assertEquals( $template, $post->page_template ); 
     145    } 
     146 
    127147    function test_get_post_filter() { 
    128148        $post = get_post( $this->factory->post->create( array( 
Note: See TracChangeset for help on using the changeset viewer.