Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design Tools: Add block instance elements color support for buttons and headings #5164

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add unit tests for applying classname for buttons and headings
  • Loading branch information
aaronrobertshaw committed Sep 7, 2023
commit 8c2fb1d5c53a813b8e7d23940fa3d697f63c3aaa
64 changes: 64 additions & 0 deletions tests/phpunit/tests/block-supports/elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,68 @@ public function test_anchor_paragraph_link_color() {
'<p class="wp-elements-1" id="anchor">Hello <a href="http://www.wordpress.org/">WordPress</a>!</p>'
);
}

/**
* Test wp_render_elements_support() with a group block that has a button
* element color set.
*
* @ticket 59309
*/
public function test_group_with_button_element_style() {
$result = self::make_unique_id_one(
wp_render_elements_support(
'<div class="wp-block-group"><div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex"><div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Button</a></div></div></div>',
array(
'blockName' => 'core/group',
'attrs' => array(
'style' => array(
'elements' => array(
'button' => array(
'color' => array(
'text' => 'var:preset|color|vivid-red',
),
),
),
),
),
)
)
);
$this->assertSame(
$result,
'<div class="wp-block-group wp-elements-1"><div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex"><div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Button</a></div></div></div>'
);
}

/**
* Test wp_render_elements_support() with a group block that has a heading
* element color set.
*
* @ticket 59309
*/
public function test_group_with_heading_element_style() {
$result = self::make_unique_id_one(
wp_render_elements_support(
'<div class="wp-block-group"><h2 class="wp-block-heading">Test</h2></div>',
array(
'blockName' => 'core/group',
'attrs' => array(
'style' => array(
'elements' => array(
'heading' => array(
'color' => array(
'text' => 'var:preset|color|vivid-red',
),
),
),
),
),
)
)
);
$this->assertSame(
$result,
'<div class="wp-block-group wp-elements-1"><h2 class="wp-block-heading">Test</h2></div>'
);
}
}