Fixed Broken Cache Test When Path Tokenized

Since the template path is tokenized, it's possible that in different
testing environments the contents of the cache will be different
than the template file path on the filesystem. We can make sure
they are the same by untokenizing the cached path before the
assertion.
This commit is contained in:
Christopher Allford 2023-04-18 10:13:17 -07:00
parent c5cec0fe30
commit 5ca9c47563
1 changed files with 3 additions and 1 deletions

View File

@ -43,7 +43,9 @@ class WC_Template_Cache extends WC_Unit_Test_Case {
// Check individual templates.
foreach ( $templates as $cache_key => $template ) {
$this->assertEquals( $template, wp_cache_get( $cache_key, 'woocommerce' ) );
// The cache contents may be tokenized and we need to untokenize it for the assertion.
$from_cache = wc_untokenize_path( wp_cache_get( $cache_key, 'woocommerce' ), wc_get_path_define_tokens() );
$this->assertEquals( $template, $from_cache );
}
// Clear cache.