Fixes a WP nightly unity test (#34190)

* Dont check for cache when there are no cached templates.

* Add changelog.
This commit is contained in:
Vedanshu Jain 2022-08-04 18:30:39 +05:30 committed by GitHub
parent 0e0212254e
commit 5f0efcf02f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Fixes a unit test for WP nightly. No functional change.

View File

@ -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' ) );
}