Make WordPress Core

Changeset 53774


Ignore:
Timestamp:
07/25/2022 01:46:23 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/template.php

    r53773 r53774  
    1717    public $custom_logo_id;
    1818    public $custom_logo_url;
     19
     20    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     21        /*
     22         * Declare theme support for custom logo.
     23         *
     24         * This ensures that the `site_logo` option gets deleted in
     25         * _delete_site_logo_on_remove_theme_mods(), which in turn
     26         * prevents the `core/site-logo` block filters from affecting
     27         * the custom logo tests.
     28         *
     29         * Alternatively, these filters can be removed instead:
     30         *
     31         *     remove_filter( 'theme_mod_custom_logo', '_override_custom_logo_theme_mod' );
     32         *     remove_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
     33         */
     34        add_theme_support( 'custom-logo' );
     35    }
     36
     37    public static function wpTearDownAfterClass() {
     38        remove_theme_support( 'custom-logo' );
     39    }
    1940
    2041    public function set_up() {
Note: See TracChangeset for help on using the changeset viewer.