diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index 38d473065f..6515e385eb 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -398,25 +398,22 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { /** * @ticket 24330 * - * setup_postdata( $a_post ) followed by the_content() in a loop that does not update - * global $post should use the content of $a_post rather then the global post. + * setup_postdata( $a_post ) followed by the_content() without updating global $post + * should use the content of $a_post rather then the global post. */ - function test_setup_postdata_loop() { + function test_setup_postdata_with_the_content() { $post_id = self::factory()->post->create( array( 'post_content' => 'global post' ) ); $GLOBALS['post'] = get_post( $post_id ); $GLOBALS['wp_query']->post = $GLOBALS['post']; - $ids = self::factory()->post->create_many( 5 ); - foreach ( $ids as $id ) { - $page = get_post( $id ); - if ( $page ) { - setup_postdata( $page ); - $content = get_echo( 'the_content', array() ); - $this->assertEquals( $post_id, $GLOBALS['post']->ID ); - $this->assertNotEquals( '

global post

', strip_ws( $content ) ); - wp_reset_postdata(); - } - } + $a_post_id = self::factory()->post->create(); + $a_post = get_post( $a_post_id ); + + setup_postdata( $a_post ); + $content = get_echo( 'the_content' ); + $this->assertEquals( $post_id, $GLOBALS['post']->ID ); + $this->assertNotEquals( '

global post

', strip_ws( $content ) ); + wp_reset_postdata(); } /**