diff --git a/tests/phpunit/tests/functions/getArchives.php b/tests/phpunit/tests/functions/getArchives.php index 532254fa5e..b39f7dbb6d 100644 --- a/tests/phpunit/tests/functions/getArchives.php +++ b/tests/phpunit/tests/functions/getArchives.php @@ -127,11 +127,9 @@ EOF; } function test_wp_get_archives_echo() { - $expected['echo'] = "
  • " . date( 'F Y' ) . '
  • '; - ob_start(); + $expected['echo'] = "\t
  • " . date( 'F Y' ) . '
  • ' . "\n"; + $this->expectOutputString( $expected['echo'] ); wp_get_archives( array( 'echo' => true ) ); - $actual = ob_get_clean(); - $this->assertEquals( $expected['echo'], trim( $actual ) ); } function test_wp_get_archives_order() { diff --git a/tests/phpunit/tests/post/listPages.php b/tests/phpunit/tests/post/listPages.php index 6954c52da5..1261d909b1 100644 --- a/tests/phpunit/tests/post/listPages.php +++ b/tests/phpunit/tests/post/listPages.php @@ -238,10 +238,8 @@ class Tests_List_Pages extends WP_UnitTestCase {
  • Parent 2
  • Parent 3
  • '; - ob_start(); + $this->expectOutputString( $expected['echo'] ); wp_list_pages( $args ); - $actual = ob_get_clean(); - $this->AssertEquals( $expected['echo'], $actual ); } function test_wp_list_pages_authors() { diff --git a/tests/phpunit/tests/post/thumbnails.php b/tests/phpunit/tests/post/thumbnails.php index d159839819..aad293affa 100644 --- a/tests/phpunit/tests/post/thumbnails.php +++ b/tests/phpunit/tests/post/thumbnails.php @@ -141,10 +141,8 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { set_post_thumbnail( $post_id, $attachment_id ); - ob_start(); + $this->expectOutputString( $caption ); the_post_thumbnail_caption( $post_id ); - - $this->assertEquals( $caption, ob_get_clean() ); } function test_get_the_post_thumbnail() { @@ -166,19 +164,14 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { } function test_the_post_thumbnail() { - ob_start(); - the_post_thumbnail(); - $actual = ob_get_clean(); - $this->assertEquals( '', $actual ); + $this->expectOutputString( '' ); + the_post_thumbnail(); $GLOBALS['post'] = self::$post; - ob_start(); + $this->expectOutputString( '' ); the_post_thumbnail(); - $actual = ob_get_clean(); - - $this->assertEquals( '', $actual ); set_post_thumbnail( self::$post, self::$attachment_id ); @@ -188,11 +181,8 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { ) ); - ob_start(); + $this->expectOutputString( $expected ); the_post_thumbnail(); - $actual = ob_get_clean(); - - $this->assertEquals( $expected, $actual ); } /** @@ -233,25 +223,13 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { function test_the_post_thumbnail_url() { $GLOBALS['post'] = self::$post; - ob_start(); + $this->expectOutputString( '' ); the_post_thumbnail_url(); - $actual = ob_get_clean(); - - $this->assertEmpty( $actual ); - - ob_start(); - the_post_thumbnail_url(); - $actual = ob_get_clean(); - - $this->assertEmpty( $actual ); set_post_thumbnail( self::$post, self::$attachment_id ); - ob_start(); + $this->expectOutputString( wp_get_attachment_url( self::$attachment_id ) ); the_post_thumbnail_url(); - $actual = ob_get_clean(); - - $this->assertEquals( wp_get_attachment_url( self::$attachment_id ), $actual ); } /** diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 579f648667..d651b121ff 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -66,13 +66,11 @@ class Tests_Taxonomy extends WP_UnitTestCase { function test_the_taxonomies() { $post_id = self::factory()->post->create(); - ob_start(); + $this->expectOutputString( sprintf( + 'Categories: Uncategorized.', + get_category_link( 1 ) + ) ); the_taxonomies( array( 'post' => $post_id ) ); - $output = ob_get_clean(); - - $link = get_category_link( 1 ); - $expected = 'Categories: Uncategorized.'; - $this->assertEquals( $expected, $output ); } /** diff --git a/tests/phpunit/tests/user/listAuthors.php b/tests/phpunit/tests/user/listAuthors.php index 497b0fb6b5..1568c34680 100644 --- a/tests/phpunit/tests/user/listAuthors.php +++ b/tests/phpunit/tests/user/listAuthors.php @@ -161,10 +161,8 @@ class Tests_User_ListAuthors extends WP_UnitTestCase { function test_wp_list_authors_echo() { $expected['echo'] = '
  • bob
  • paul
  • zack
  • '; - ob_start(); + $this->expectOutputString( $expected['echo'] ); wp_list_authors( array( 'echo' => true ) ); - $actual = ob_get_clean(); - $this->AssertEquals( $expected['echo'], $actual ); } function test_wp_list_authors_feed() {