Changeset 48113 for trunk/tests/phpunit/tests/query/setupPostdata.php
- Timestamp:
- 06/21/2020 10:28:52 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/setupPostdata.php
r46586 r48113 399 399 * @ticket 24330 400 400 * 401 * setup_postdata( $a_post ) followed by the_content() in a loop that does not update402 * global $postshould use the content of $a_post rather then the global post.403 */ 404 function test_setup_postdata_ loop() {401 * setup_postdata( $a_post ) followed by the_content() without updating global $post 402 * should use the content of $a_post rather then the global post. 403 */ 404 function test_setup_postdata_with_the_content() { 405 405 $post_id = self::factory()->post->create( array( 'post_content' => 'global post' ) ); 406 406 $GLOBALS['post'] = get_post( $post_id ); 407 407 $GLOBALS['wp_query']->post = $GLOBALS['post']; 408 408 409 $ids = self::factory()->post->create_many( 5 ); 410 foreach ( $ids as $id ) { 411 $page = get_post( $id ); 412 if ( $page ) { 413 setup_postdata( $page ); 414 $content = get_echo( 'the_content', array() ); 415 $this->assertEquals( $post_id, $GLOBALS['post']->ID ); 416 $this->assertNotEquals( '<p>global post</p>', strip_ws( $content ) ); 417 wp_reset_postdata(); 418 } 419 } 409 $a_post_id = self::factory()->post->create(); 410 $a_post = get_post( $a_post_id ); 411 412 setup_postdata( $a_post ); 413 $content = get_echo( 'the_content' ); 414 $this->assertEquals( $post_id, $GLOBALS['post']->ID ); 415 $this->assertNotEquals( '<p>global post</p>', strip_ws( $content ) ); 416 wp_reset_postdata(); 420 417 } 421 418
Note: See TracChangeset
for help on using the changeset viewer.