From 36fcd57c911f50e3089c594fc5b54033400ee19e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 25 Jul 2022 13:46:23 +0000 Subject: [PATCH] Tests: Declare `custom-logo` theme support for custom logo tests. This addresses failures in `has_custom_logo()` and `get_custom_logo()` tests when being run separately: {{{ 1) Tests_General_Template::test_has_custom_logo Custom logo should not be set after removal. Failed asserting that true is false. tests/phpunit/tests/general/template.php:291 2) Tests_General_Template::test_get_custom_logo Custom logo should not be set after removal. Failed asserting that a string is empty. tests/phpunit/tests/general/template.php:336 }}} Specifically, this ensures that the `site_logo` option gets deleted in `_delete_site_logo_on_remove_theme_mods()`, which in turn prevents the `core/site-logo` block filters from affecting the custom logo tests. Alternatively, these filters could be removed instead: {{{ remove_filter( 'theme_mod_custom_logo', '_override_custom_logo_theme_mod' ); remove_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' ); }}} Follow-up to [36905], [51091], [51421], [52042]. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53774 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/general/template.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index 4e412fd077..06c9c9ddb8 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -17,6 +17,27 @@ class Tests_General_Template extends WP_UnitTestCase { public $custom_logo_id; public $custom_logo_url; + public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { + /* + * Declare theme support for custom logo. + * + * This ensures that the `site_logo` option gets deleted in + * _delete_site_logo_on_remove_theme_mods(), which in turn + * prevents the `core/site-logo` block filters from affecting + * the custom logo tests. + * + * Alternatively, these filters can be removed instead: + * + * remove_filter( 'theme_mod_custom_logo', '_override_custom_logo_theme_mod' ); + * remove_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' ); + */ + add_theme_support( 'custom-logo' ); + } + + public static function wpTearDownAfterClass() { + remove_theme_support( 'custom-logo' ); + } + public function set_up() { parent::set_up();