#42098 closed enhancement (fixed)
Simplify output tests with expectOutputString()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch |
Focuses: | Cc: |
Description
PHPUnit has methods to test output, e.g.:
expectOutputString() expectOutputRegex()
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.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
In 42098.diff simplifies output tests in: