Make WordPress Core

Changeset 1287 in tests


Ignore:
Timestamp:
05/20/2013 11:07:00 AM (13 years ago)
Author:
ryan
Message:

Tests for the_content, the_remaining_content, wp_parse_post_content. see #WP24330

Location:
trunk/tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/post.php

    r1246 r1287  
    623623
    624624    }
     625
     626    function test_wp_parse_post_content_single_page() {
     627        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) );
     628        $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() {
     637        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
     638        $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() {
     647        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0' ) );
     648        $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() {
     657        $post_id = $this->factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
     658        $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'] );
     664    }
    625665}
  • trunk/tests/post/output.php

    r1285 r1287  
    171171        kses_remove_filters();
    172172    }
     173
     174    function test_the_content_with_id() {
     175        $post_content = <<<EOF
     176test_the_content_with_id <i>This is the excerpt.</i>
     177<!--more-->
     178This is the <b>body</b>.
     179EOF;
     180
     181        $post_id = $this->factory->post->create( compact( 'post_content' ) );
     182
     183        $expected = <<<EOF
     184<p>test_the_content_with_id <i>This is the excerpt.</i><br />
     185<span id="more-{$post_id}"></span><br />
     186This is the <b>body</b>.</p>
     187EOF;
     188
     189        $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content', array( null, false, $post_id ) ) ) );
     190    }
     191
     192    function test_the_remaining_content_with_id() {
     193        $post_content = <<<EOF
     194test_the_remaining_content_with_id <i>This is the excerpt.</i>
     195<!--more-->
     196This is the <b>body</b>.
     197EOF;
     198
     199        $post_id = $this->factory->post->create( compact( 'post_content' ) );
     200
     201        $expected = <<<EOF
     202<p>test_the_remaining_content_with_id <i>This is the excerpt.</i><br />
     203<span id="more-{$post_id}"></span><br />
     204This is the <b>body</b>.</p>
     205EOF;
     206
     207        $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_remaining_content', array( null, false, $post_id ) ) ) );
     208    }
    173209}
  • trunk/tests/query.php

    r1286 r1287  
    1717
    1818    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' ) );
     19        $post = $this->factory->post->create_and_get( array( 'post_content' => 'Page 0' ) );
    2020        setup_postdata( $post );
    2121
Note: See TracChangeset for help on using the changeset viewer.