mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Editor: add layout classes to legacy Group inner container.
Moves generated layout classes into the Group block inner container in classic themes, so that block gap support can work correctly. Props flixos90, mukesh27. Fixes #60130. git-svn-id: https://develop.svn.wordpress.org/trunk@57246 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -252,4 +252,94 @@ class Test_Block_Supports_Layout extends WP_UnitTestCase {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that wp_restore_group_inner_container() restores the legacy inner container on the Group block.
|
||||
*
|
||||
* @ticket 60130
|
||||
*
|
||||
* @covers ::wp_restore_group_inner_container
|
||||
*
|
||||
* @dataProvider data_restore_group_inner_container
|
||||
*
|
||||
* @param array $args Dataset to test.
|
||||
* @param string $expected_output The expected output.
|
||||
*/
|
||||
public function test_restore_group_inner_container( $args, $expected_output ) {
|
||||
$actual_output = wp_restore_group_inner_container( $args['block_content'], $args['block'] );
|
||||
$this->assertEquals( $expected_output, $actual_output );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_restore_group_inner_container.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data_restore_group_inner_container() {
|
||||
return array(
|
||||
'group block with existing inner container' => array(
|
||||
'args' => array(
|
||||
'block_content' => '<div class="wp-block-group"><div class="wp-block-group__inner-container"></div></div>',
|
||||
'block' => array(
|
||||
'blockName' => 'core/group',
|
||||
'attrs' => array(
|
||||
'layout' => array(
|
||||
'type' => 'default',
|
||||
),
|
||||
),
|
||||
'innerBlocks' => array(),
|
||||
'innerHTML' => '<div class="wp-block-group"><div class="wp-block-group__inner-container"></div></div>',
|
||||
'innerContent' => array(
|
||||
'<div class="wp-block-group"><div class="wp-block-group__inner-container">',
|
||||
' ',
|
||||
' </div></div>',
|
||||
),
|
||||
),
|
||||
),
|
||||
'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-container"></div></div>',
|
||||
),
|
||||
'group block with no existing inner container' => array(
|
||||
'args' => array(
|
||||
'block_content' => '<div class="wp-block-group"></div>',
|
||||
'block' => array(
|
||||
'blockName' => 'core/group',
|
||||
'attrs' => array(
|
||||
'layout' => array(
|
||||
'type' => 'default',
|
||||
),
|
||||
),
|
||||
'innerBlocks' => array(),
|
||||
'innerHTML' => '<div class="wp-block-group"></div>',
|
||||
'innerContent' => array(
|
||||
'<div class="wp-block-group">',
|
||||
' ',
|
||||
' </div>',
|
||||
),
|
||||
),
|
||||
),
|
||||
'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-container"></div></div>',
|
||||
),
|
||||
'group block with layout classnames' => array(
|
||||
'args' => array(
|
||||
'block_content' => '<div class="wp-block-group is-layout-constrained wp-block-group-is-layout-constrained"></div>',
|
||||
'block' => array(
|
||||
'blockName' => 'core/group',
|
||||
'attrs' => array(
|
||||
'layout' => array(
|
||||
'type' => 'default',
|
||||
),
|
||||
),
|
||||
'innerBlocks' => array(),
|
||||
'innerHTML' => '<div class="wp-block-group"></div>',
|
||||
'innerContent' => array(
|
||||
'<div class="wp-block-group">',
|
||||
' ',
|
||||
' </div>',
|
||||
),
|
||||
),
|
||||
),
|
||||
'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained"></div></div>',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user