WordPress.org

Make WordPress Core

Changeset 1307 in tests


Ignore:
Timestamp:
07/09/13 05:24:32 (12 months ago)
Author:
nacin
Message:

Update post content parsing tests for [24598] and add new tests for [24599]. see #16746.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/post.php

    r1287 r1307  
    624624    } 
    625625 
    626     function test_wp_parse_post_content_single_page() { 
     626    function test_parse_post_content_single_page() { 
     627        global $multipage, $pages, $numpages; 
    627628        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) ); 
    628629        $post = get_post( $post_id ); 
    629         $content = wp_parse_post_content( $post ); 
    630         $this->assertEquals( 0, $content['multipage'] ); 
    631         $this->assertCount(  1, $content['pages']     ); 
    632         $this->assertEquals( 1, $content['numpages']  ); 
    633         $this->assertEquals( array( 'Page 0' ), $content['pages'] ); 
    634     } 
    635  
    636     function test_wp_parse_post_content_multi_page() { 
     630        setup_postdata( $post ); 
     631        $this->assertEquals( 0, $multipage ); 
     632        $this->assertCount(  1, $pages ); 
     633        $this->assertEquals( 1, $numpages ); 
     634        $this->assertEquals( array( 'Page 0' ), $pages ); 
     635    } 
     636 
     637    function test_parse_post_content_multi_page() { 
     638        global $multipage, $pages, $numpages; 
    637639        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 
    638640        $post = get_post( $post_id ); 
    639         $content = wp_parse_post_content( $post ); 
    640         $this->assertEquals( 1, $content['multipage'] ); 
    641         $this->assertCount(  4, $content['pages']     ); 
    642         $this->assertEquals( 4, $content['numpages']  ); 
    643         $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $content['pages'] ); 
    644     } 
    645  
    646     function test_wp_parse_post_content_remaining_single_page() { 
     641        setup_postdata( $post ); 
     642        $this->assertEquals( 1, $multipage ); 
     643        $this->assertCount(  4, $pages ); 
     644        $this->assertEquals( 4, $numpages ); 
     645        $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); 
     646    } 
     647 
     648    function test_parse_post_content_remaining_single_page() { 
     649        global $multipage, $pages, $numpages; 
    647650        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) ); 
    648651        $post = get_post( $post_id ); 
    649         $content = wp_parse_post_content( $post, true ); 
    650         $this->assertEquals( 0, $content['multipage'] ); 
    651         $this->assertCount(  1, $content['pages']     ); 
    652         $this->assertEquals( 1, $content['numpages']  ); 
    653         $this->assertEquals( array( 'Page 0' ), $content['pages'] ); 
    654     } 
    655  
    656     function test_wp_parse_post_content_remaining_multi_page() { 
     652        setup_postdata( $post ); 
     653        $this->assertEquals( 0, $multipage ); 
     654        $this->assertCount(  1, $pages ); 
     655        $this->assertEquals( 1, $numpages ); 
     656        $this->assertEquals( array( 'Page 0' ), $pages ); 
     657    } 
     658 
     659    function test_parse_post_content_remaining_multi_page() { 
     660        global $multipage, $pages, $numpages; 
    657661        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 
    658662        $post = get_post( $post_id ); 
    659         $content = wp_parse_post_content( $post, true ); 
    660         $this->assertEquals( 1, $content['multipage'] ); 
    661         $this->assertCount(  4, $content['pages']     ); 
    662         $this->assertEquals( 4, $content['numpages']  ); 
    663         $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $content['pages'] ); 
     663        setup_postdata( $post ); 
     664        $this->assertEquals( 1, $multipage ); 
     665        $this->assertCount(  4, $pages ); 
     666        $this->assertEquals( 4, $numpages ); 
     667        $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); 
     668    } 
     669 
     670    /** 
     671     * @ticket 16746 
     672     */ 
     673    function test_parse_post_content_starting_with_nextpage() { 
     674        global $multipage, $pages, $numpages; 
     675        $post_id = $this->factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 
     676        $post = get_post( $post_id ); 
     677        setup_postdata( $post ); 
     678        $this->assertEquals( 1, $multipage ); 
     679        $this->assertCount(  4, $pages ); 
     680        $this->assertEquals( 4, $numpages ); 
     681        $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); 
     682    } 
     683 
     684    /** 
     685     * @ticket 16746 
     686     */ 
     687    function test_parse_post_content_starting_with_nextpage_multi() { 
     688        global $multipage, $pages, $numpages; 
     689        $post_id = $this->factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) ); 
     690        $post = get_post( $post_id ); 
     691        setup_postdata( $post ); 
     692        $this->assertEquals( 0, $multipage ); 
     693        $this->assertCount(  1, $pages ); 
     694        $this->assertEquals( 1, $numpages ); 
     695        $this->assertEquals( array( 'Page 0' ), $pages ); 
    664696    } 
    665697} 
Note: See TracChangeset for help on using the changeset viewer.