Skip to content

Commit

Permalink
Add unit testing to duotone CSS declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Nov 2, 2023
1 parent f97e951 commit fa7a0bf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions phpunit/class-wp-duotone-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down

0 comments on commit fa7a0bf

Please sign in to comment.