WordPress.org

Make WordPress Core

Changeset 1286 in tests


Ignore:
Timestamp:
05/16/13 21:36:53 (11 months ago)
Author:
ryan
Message:

setup_postdata() tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/query.php

    r1242 r1286  
    1515        $this->assertEquals( array( 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] ); 
    1616    } 
     17 
     18    function test_setup_postdata_single_page() { 
     19        $post = $this->factory->post->create_and_get( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 
     20        setup_postdata( $post ); 
     21 
     22        $this->assertEquals( 0, $GLOBALS['multipage'] ); 
     23        $this->assertCount(  1, $GLOBALS['pages']     ); 
     24        $this->assertEquals( 1, $GLOBALS['numpages']  ); 
     25        $this->assertEquals( array( 'Page 0' ), $GLOBALS['pages'] ); 
     26    } 
     27 
     28    function test_setup_postdata_multi_page() { 
     29        $post = $this->factory->post->create_and_get( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 
     30        setup_postdata( $post ); 
     31 
     32        $this->assertEquals( 1, $GLOBALS['multipage'] ); 
     33        $this->assertCount(  4, $GLOBALS['pages']     ); 
     34        $this->assertEquals( 4, $GLOBALS['numpages']  ); 
     35        $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] ); 
     36    } 
    1737} 
Note: See TracChangeset for help on using the changeset viewer.