Editor: Use a non-persistent object cache instead of transient in wp_get_global_stylesheet().

This changeset is part of a greater effort to enhance the caching strategy for theme.json based data. Similar to [55138], [55148], and [55155], the cache is currently ignored when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.

Props spacedmonkey, oandregal, flixos90, ajlende, hellofromtonya.
Fixes #57568.


git-svn-id: https://develop.svn.wordpress.org/trunk@55185 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz
2023-02-01 22:57:04 +00:00
parent 888e139a94
commit 6b4b2eb60f
2 changed files with 49 additions and 12 deletions

View File

@@ -0,0 +1,37 @@
<?php
/**
* Tests wp_get_global_styles_svg_filters().
*
* @group themes
*/
class Tests_Theme_wpGetGlobalStylesSvgFilters extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
// Clear caches.
wp_clean_themes_cache();
}
public function tear_down() {
wp_clean_themes_cache();
parent::tear_down();
}
/**
* Tests that switching themes recalculates the svgs.
*
* @covers ::wp_get_global_styles_svg_filters
*
* @ticket 57568
*/
public function test_switching_themes_should_recalculate_svg() {
$svg_for_default_theme = wp_get_global_styles_svg_filters();
switch_theme( 'block-theme' );
$svg_for_block_theme = wp_get_global_styles_svg_filters();
switch_theme( WP_DEFAULT_THEME );
$this->assertStringContainsString( '<svg', $svg_for_default_theme, 'Default theme should contain SVG' );
$this->assertStringContainsString( '<svg', $svg_for_default_theme, 'Block theme should contain SVG' );
$this->assertNotSame( $svg_for_default_theme, $svg_for_block_theme, 'Cache value should have changed' );
}
}