diff --git a/tests/phpunit/tests/general/getTheGenerator.php b/tests/phpunit/tests/general/getTheGenerator.php index 62100e9d1b2b7..f9d95b790be96 100644 --- a/tests/phpunit/tests/general/getTheGenerator.php +++ b/tests/phpunit/tests/general/getTheGenerator.php @@ -89,6 +89,42 @@ public function test_get_the_generator_returns_null_when_type_empty() { $this->assertNull( get_the_generator( '' ) ); } + /** + * Tests that an empty $type is inferred from the current filter. + * + * @ticket 66832 + * + * @dataProvider data_generator_type_from_current_filter + * + * @param string $filter Current filter name. + * @param string $type Expected inferred generator type. + */ + public function test_get_the_generator_infers_type_from_current_filter( $filter, $type ) { + global $wp_current_filter; + + $wp_current_filter = array( $filter ); + + $this->assertSame( get_the_generator( $type ), get_the_generator() ); + } + + /** + * Data provider for test_get_the_generator_infers_type_from_current_filter(). + * + * @return array[] + */ + public static function data_generator_type_from_current_filter() { + return array( + 'rss2_head' => array( 'rss2_head', 'rss2' ), + 'commentsrss2_head' => array( 'commentsrss2_head', 'rss2' ), + 'rss_head' => array( 'rss_head', 'comment' ), + 'opml_head' => array( 'opml_head', 'comment' ), + 'rdf_header' => array( 'rdf_header', 'rdf' ), + 'atom_head' => array( 'atom_head', 'atom' ), + 'comments_atom_head' => array( 'comments_atom_head', 'atom' ), + 'app_head' => array( 'app_head', 'atom' ), + ); + } + /** * Tests that get_the_generator_$type filter modifies the generator markup. *