From 5f0efcf02f9e9af0c687028c4748c54afd22a81d Mon Sep 17 00:00:00 2001 From: Vedanshu Jain Date: Thu, 4 Aug 2022 18:30:39 +0530 Subject: [PATCH] Fixes a WP nightly unity test (#34190) * Dont check for cache when there are no cached templates. * Add changelog. --- plugins/woocommerce/changelog/fix-unit-nightly | 5 +++++ .../tests/legacy/unit-tests/core/template-cache.php | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 plugins/woocommerce/changelog/fix-unit-nightly diff --git a/plugins/woocommerce/changelog/fix-unit-nightly b/plugins/woocommerce/changelog/fix-unit-nightly new file mode 100644 index 00000000000..acaf6bd11e7 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-unit-nightly @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Fixes a unit test for WP nightly. No functional change. + + diff --git a/plugins/woocommerce/tests/legacy/unit-tests/core/template-cache.php b/plugins/woocommerce/tests/legacy/unit-tests/core/template-cache.php index f1658e17d8d..d429115615b 100644 --- a/plugins/woocommerce/tests/legacy/unit-tests/core/template-cache.php +++ b/plugins/woocommerce/tests/legacy/unit-tests/core/template-cache.php @@ -57,8 +57,10 @@ class WC_Template_Cache extends WC_Unit_Test_Case { $cached_templates = wp_cache_get( 'cached_templates', 'woocommerce' ); wc_clear_template_cache(); - foreach ( (array) $cached_templates as $template ) { - $this->assertEmpty( wp_cache_get( $template, 'woocommerce' ) ); + if ( $cached_templates ) { + foreach ( (array) $cached_templates as $template ) { + $this->assertEmpty( wp_cache_get( $template, 'woocommerce' ) ); + } } $this->assertEmpty( wp_cache_get( 'cached_templates', 'woocommerce' ) ); }