[wp-trac] [WordPress Trac] #42098: Simplify output tests with expectOutputString()

WordPress Trac noreply at wordpress.org
Wed Oct 4 21:36:09 UTC 2017


#42098: Simplify output tests with expectOutputString()
------------------------------+-----------------------------
 Reporter:  birgire           |      Owner:
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 PHPUnit has methods to test output, e.g.:

 {{{
 expectOutputString()
 expectOutputRegex()

 }}}

 https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html
 #writing-tests-for-phpunit.output

 We could use them to simplify tests.

 '''Example:
 '''
 Before:

 {{{
 ob_start();
 the_post_thumbnail();
 $actual = ob_get_clean();
 $this->assertEquals( '', $actual );

 }}}

 After:


 {{{
 $this->expectOutputString( '' );
 the_post_thumbnail();

 }}}

 Currently used in files:

 {{{
 tests/phpunit/tests/general/template.php
 tests/phpunit/tests/general/document-title.php
 tests/phpunit/tests/general/resourceHints.php
 tests/phpunit/tests/oembed/WpEmbed.php

 }}}

 We could scope this ticket to e.g. the files:

 {{{
 tests/phpunit/tests/post/thumbnails.php
 tests/phpunit/tests/post/listPages.php
 tests/phpunit/tests/user/listAuthors.php
 tests/phpunit/tests/functions/getArchives.php
 tests/phpunit/tests/taxonomy.php
 }}}

 to begin with.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42098>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list