Changeset 30085 for trunk/tests/phpunit/tests/query.php
- Timestamp:
- 10/29/2014 02:31:37 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query.php
r28967 r30085 13 13 14 14 $wp_rewrite->flush_rules(); 15 }16 17 /**18 * @ticket 1674619 */20 function test_nextpage_at_start_of_content() {21 $post = $this->factory->post->create_and_get( array( 'post_content' => '<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );22 setup_postdata( $post );23 24 $this->assertEquals( 1, $GLOBALS['multipage'] );25 $this->assertCount( 3, $GLOBALS['pages'] );26 $this->assertEquals( 3, $GLOBALS['numpages'] );27 $this->assertEquals( array( 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] );28 }29 30 function test_setup_postdata_single_page() {31 $post = $this->factory->post->create_and_get( array( 'post_content' => 'Page 0' ) );32 setup_postdata( $post );33 34 $this->assertEquals( 0, $GLOBALS['multipage'] );35 $this->assertCount( 1, $GLOBALS['pages'] );36 $this->assertEquals( 1, $GLOBALS['numpages'] );37 $this->assertEquals( array( 'Page 0' ), $GLOBALS['pages'] );38 }39 40 function test_setup_postdata_multi_page() {41 $post = $this->factory->post->create_and_get( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );42 setup_postdata( $post );43 44 $this->assertEquals( 1, $GLOBALS['multipage'] );45 $this->assertCount( 4, $GLOBALS['pages'] );46 $this->assertEquals( 4, $GLOBALS['numpages'] );47 $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] );48 }49 50 /**51 * @ticket 2433052 *53 * setup_postdata( $a_post ) followed by the_content() in a loop that does not update54 * global $post should use the content of $a_post rather then the global post.55 */56 function test_setup_postdata_loop() {57 $post_id = $this->factory->post->create( array( 'post_content' => 'global post' ) );58 $GLOBALS['wp_query']->post = $GLOBALS['post'] = get_post( $post_id );59 60 $ids = $this->factory->post->create_many(5);61 foreach ( $ids as $id ) {62 $page = get_post( $id );63 if ( $page ) {64 setup_postdata( $page );65 $content = get_echo( 'the_content', array() );66 $this->assertEquals( $post_id, $GLOBALS['post']->ID );67 $this->assertNotEquals( '<p>global post</p>', strip_ws( $content ) );68 wp_reset_postdata();69 }70 }71 15 } 72 16
Note: See TracChangeset
for help on using the changeset viewer.