From e7c543f997f9cddfd33c9d239544ee494aa8e61c Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 11 Sep 2013 21:32:14 +0000 Subject: [PATCH] Restore the test code for `get_theme()`, add the notice suppression filters, and fix the type in the `remove_filter()` call. See #25282. git-svn-id: https://develop.svn.wordpress.org/trunk@25362 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/admin/includesTheme.php | 23 +++++++++++++++++++++ tests/phpunit/tests/theme.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index a0b45e7ac2..a0e6707f46 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -17,6 +17,18 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase { // clear caches wp_clean_themes_cache(); unset( $GLOBALS['wp_themes'] ); + + add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) ); + } + + function deprecated_function_run_check( $function ) { + if ( in_array( $function, array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' ) ) ) + add_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) ); + } + + function filter_deprecated_function_trigger_error() { + remove_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) ); + return false; } function tearDown() { @@ -40,6 +52,17 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase { * @ticket 11216 */ function test_page_templates() { + $theme = get_theme( 'Page Template Theme' ); + $this->assertNotEmpty( $theme ); + + switch_theme( $theme['Template'], $theme['Stylesheet'] ); + + $templates = get_page_templates(); + $this->assertCount( 3, $templates ); + $this->assertEquals( "template-top-level.php", $templates['Top Level'] ); + $this->assertEquals( "subdir/template-sub-dir.php", $templates['Sub Dir'] ); + $this->assertEquals( "template-header.php", $templates['This Template Header Is On One Line'] ); + $theme = wp_get_theme( 'page-templates' ); $this->assertNotEmpty( $theme ); diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index 5f11630b3d..8618f58766 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -25,7 +25,7 @@ class Tests_Theme extends WP_UnitTestCase { } function filter_deprecated_function_trigger_error() { - remove_filter( 'filter_deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) ); + remove_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) ); return false; }