Themes: Add a test to ensure get_template_part()
does not return a value.
This function must not be modified to return anything due to existing themes which output the return value, for example via `echo get_template_part( ... )`. See #40969 git-svn-id: https://develop.svn.wordpress.org/trunk@46328 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c61471a495
commit
6b983b1d5c
1
tests/phpunit/data/themedir1/default/template-part.php
Normal file
1
tests/phpunit/data/themedir1/default/template-part.php
Normal file
@ -0,0 +1 @@
|
||||
Template Part
|
@ -627,4 +627,19 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
$actual_public = get_echo( 'wp_no_robots' );
|
||||
$this->assertSame( "<meta name='robots' content='noindex,follow' />\n", $actual_public );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 40969
|
||||
*/
|
||||
function test_get_template_part_returns_nothing() {
|
||||
ob_start();
|
||||
|
||||
// The `get_template_part()` function must not return anything
|
||||
// due to themes in the wild that echo its return value.
|
||||
$part = get_template_part( 'template', 'part' );
|
||||
$output = ob_get_clean();
|
||||
|
||||
self::assertSame( 'Template Part', trim( $output ) );
|
||||
self::assertSame( null, $part );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user