- Timestamp:
- 06/29/2023 06:19:41 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpGetGlobalStylesSvgFilters.php
r56042 r56101 1 <?php2 /**3 * Tests wp_get_global_styles_svg_filters().4 *5 * @group themes6 */7 class Tests_Theme_wpGetGlobalStylesSvgFilters extends WP_UnitTestCase {8 public function set_up() {9 parent::set_up();10 // Clear caches.11 wp_clean_themes_cache();12 }13 14 public function tear_down() {15 wp_clean_themes_cache();16 17 parent::tear_down();18 }19 20 /**21 * Tests that switching themes recalculates the svgs.22 *23 * @covers ::wp_get_global_styles_svg_filters24 *25 * @ticket 5756826 */27 public function test_switching_themes_should_recalculate_svg() {28 $svg_for_default_theme = wp_get_global_styles_svg_filters();29 switch_theme( 'block-theme' );30 $svg_for_block_theme = wp_get_global_styles_svg_filters();31 switch_theme( WP_DEFAULT_THEME );32 33 $this->assertStringContainsString( '<svg', $svg_for_default_theme, 'Default theme should contain SVG' );34 $this->assertStringContainsString( '<svg', $svg_for_default_theme, 'Block theme should contain SVG' );35 $this->assertNotSame( $svg_for_default_theme, $svg_for_block_theme, 'Cache value should have changed' );36 }37 38 /**39 * Tests that the function relies on the development mode for whether to use caching.40 *41 * @ticket 5748742 *43 * @covers ::wp_get_global_styles_svg_filters44 */45 public function test_caching_is_used_when_developing_theme() {46 global $_wp_tests_development_mode;47 48 switch_theme( 'block-theme' );49 50 // Store SVG in cache.51 $svg = '<svg></svg>';52 wp_cache_set( 'wp_get_global_styles_svg_filters', $svg, 'theme_json' );53 54 // By default, caching should be used, so the above value will be returned.55 $_wp_tests_development_mode = '';56 $this->assertSame( $svg, wp_get_global_styles_svg_filters(), 'Caching was not used despite development mode disabled' );57 58 // When the development mode is set to 'theme', caching should not be used.59 $_wp_tests_development_mode = 'theme';60 $this->assertNotSame( $svg, wp_get_global_styles_svg_filters(), 'Caching was used despite theme development mode' );61 }62 }
Note: See TracChangeset
for help on using the changeset viewer.