-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update comment for possible duotone attribute contents * Rename filter_preset to filter_data * Use WP_Theme_JSON for scoping the selector * Treat strings as CSS in gutenberg_get_duotone_filter_property * Base is_duotone_preset based on is_string instead of !is_array * Update comments * Rename is_duotone_custom_colors * 🇺🇸😉 * Shorten some var names * Make each attribute case explicit * Only use $filter_data for custom filters * Add comment about rendering the SVG * Fix php lint * Update comments * Fix php elseifs * Fix CSS code path * Add PHP unit tests * Fix php lint * Remove tear_down because I don't think it's used --------- Co-authored-by: scruffian <ben@scruffian.com>
- Loading branch information
Showing
2 changed files
with
74 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* Test the block duotone support. | ||
* | ||
* @package Gutenberg | ||
*/ | ||
|
||
class WP_Block_Supports_Duotone_Test extends WP_UnitTestCase { | ||
public function test_gutenberg_render_duotone_support_preset() { | ||
$block = array( | ||
'blockName' => 'core/image', | ||
'attrs' => array( 'style' => array( 'color' => array( 'duotone' => 'var:preset|duotone|slug' ) ) ), | ||
); | ||
$block_content = '<figure class="wp-block-image size-full"><img src="/my-image.jpg" /></figure>'; | ||
$expected = '<figure class="wp-duotone-slug wp-block-image size-full"><img src="/my-image.jpg" /></figure>'; | ||
$this->assertSame( $expected, gutenberg_render_duotone_support( $block_content, $block ) ); | ||
} | ||
|
||
public function test_gutenberg_render_duotone_support_css() { | ||
$block = array( | ||
'blockName' => 'core/image', | ||
'attrs' => array( 'style' => array( 'color' => array( 'duotone' => 'unset' ) ) ), | ||
); | ||
$block_content = '<figure class="wp-block-image size-full"><img src="/my-image.jpg" /></figure>'; | ||
$expected = '/<figure class="wp-duotone-unset-\d+ wp-block-image size-full"><img src="\\/my-image.jpg" \\/><\\/figure>/'; | ||
$this->assertMatchesRegularExpression( $expected, gutenberg_render_duotone_support( $block_content, $block ) ); | ||
} | ||
|
||
public function test_gutenberg_render_duotone_support_custom() { | ||
$block = array( | ||
'blockName' => 'core/image', | ||
'attrs' => array( 'style' => array( 'color' => array( 'duotone' => array( '#FFFFFF', '#000000' ) ) ) ), | ||
); | ||
$block_content = '<figure class="wp-block-image size-full"><img src="/my-image.jpg" /></figure>'; | ||
$expected = '/<figure class="wp-duotone-ffffff-000000-\d+ wp-block-image size-full"><img src="\\/my-image.jpg" \\/><\\/figure>/'; | ||
$this->assertMatchesRegularExpression( $expected, gutenberg_render_duotone_support( $block_content, $block ) ); | ||
} | ||
|
||
} |
9189c3a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 9189c3a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4308926860
📝 Reported issues:
/test/e2e/specs/editor/blocks/navigation.spec.js