From 3e75a3318ed05f7562155127cc7d50ecba52ec58 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sun, 7 Jul 2024 14:48:38 +0530 Subject: [PATCH] Update test cases for latest WP and Gutenberg changes --- tests/php/test-amp-style-sanitizer.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/php/test-amp-style-sanitizer.php b/tests/php/test-amp-style-sanitizer.php index 68bd4963414..b2ee1a986e3 100644 --- a/tests/php/test-amp-style-sanitizer.php +++ b/tests/php/test-amp-style-sanitizer.php @@ -3518,8 +3518,18 @@ function ( $original_dom, $original_source, $amphtml_dom, $amphtml_source ) { $this->assertStringContainsString( 'admin-bar', $original_dom->body->getAttribute( 'class' ) ); $this->assertStringContainsString( 'earlyprintstyle', $original_source, 'Expected early print style to not be present.' ); - $this->assertStringContainsString( '.wp-block-audio figcaption', $amphtml_source, 'Expected block-library/style.css' ); - $this->assertStringContainsString( '[class^="wp-block-"]:not(.wp-block-gallery) figcaption', $amphtml_source, 'Expected twentyten/blocks.css' ); + if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '18.7', '>=' ) ) { + $this->assertStringContainsString( '.wp-block-audio :where(figcaption)', $amphtml_source, 'Expected block-library/style.css' ); + } else { + $this->assertStringContainsString( '.wp-block-audio figcaption', $amphtml_source, 'Expected block-library/style.css' ); + } + + if ( version_compare( strtok( get_bloginfo( 'version' ), '-' ), '6.6', '>=' ) ) { + $this->assertStringContainsString( '[class^="wp-block-"]:not(.wp-block-gallery) > figcaption', $amphtml_source, 'Expected twentyten/blocks.css' ); + } else { + $this->assertStringContainsString( '[class^="wp-block-"]:not(.wp-block-gallery) figcaption', $amphtml_source, 'Expected twentyten/blocks.css' ); + } + $amphtml_source = preg_replace( '/\s*>\s*/', '>', $amphtml_source ); // Account for variance in postcss. $this->assertStringContainsString( '.amp-wp-default-form-message>p', $amphtml_source, 'Expected amp-default.css' ); $this->assertStringContainsString( 'ab-empty-item', $amphtml_source, 'Expected admin-bar.css to still be present.' );