diff --git a/phpunit/class-wp-duotone-test.php b/phpunit/class-wp-duotone-test.php index 327e88f972861..111e12d1c81c8 100644 --- a/phpunit/class-wp-duotone-test.php +++ b/phpunit/class-wp-duotone-test.php @@ -45,6 +45,27 @@ public function test_gutenberg_render_duotone_support_custom() { $this->assertMatchesRegularExpression( $expected, WP_Duotone_Gutenberg::render_duotone_support( $block_content, $block ) ); } + + /** + * Tests whether the CSS declarations are generated even if the block content is + * empty. We need this to make the CSS output stable across paginations for + * features like the enhanced pagination of the Query block. + * + * @covers ::render_duotone_support + */ + public function test_css_declarations_are_generated_even_with_empty_block_content() { + $block = array( + 'blockName' => 'core/image', + 'attrs' => array( 'style' => array( 'color' => array( 'duotone' => 'var:preset|duotone|blue-orange' ) ) ), + ); + $wp_block = new WP_Block( $block ); + $block_css_declarations_property = new ReflectionProperty( 'WP_Duotone_Gutenberg', 'block_css_declarations' ); + $block_css_declarations_property->setAccessible( true ); + $block_css_declarations_property->setValue( array() ); + WP_Duotone_Gutenberg::render_duotone_support( '', $block, $wp_block ); + $this->assertNotEmpty( $block_css_declarations_property->getValue() ); + } + public function data_get_slug_from_attribute() { return array( 'pipe-slug' => array( 'var:preset|duotone|blue-orange', 'blue-orange' ),