diff --git a/tests/phpunit/data/themedir1/default/template-part.php b/tests/phpunit/data/themedir1/default/template-part.php new file mode 100644 index 0000000000..05c759fcbb --- /dev/null +++ b/tests/phpunit/data/themedir1/default/template-part.php @@ -0,0 +1 @@ +Template Part diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index fa6636170c..648e22661a 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -627,4 +627,19 @@ class Tests_General_Template extends WP_UnitTestCase { $actual_public = get_echo( 'wp_no_robots' ); $this->assertSame( "\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 ); + } }