Skip to content
Permalink
Browse files

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
  • Loading branch information...
johnbillion committed Sep 26, 2019
1 parent c61471a commit 6b983b1d5c432b7e219d81ad3f8a17f2e383dad6
Showing with 16 additions and 0 deletions.
  1. +1 −0 tests/phpunit/data/themedir1/default/template-part.php
  2. +15 −0 tests/phpunit/tests/general/template.php
@@ -0,0 +1 @@
Template Part
@@ -627,4 +627,19 @@ function test_wp_no_robots() {
$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 );
}
}

0 comments on commit 6b983b1

Please sign in to comment.
You can’t perform that action at this time.