Skip to content

Commit

Permalink
Add tests for gutenberg_render_layout_support_flag (#47719)
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines authored Feb 5, 2023
1 parent 4ef110c commit c5104af
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions phpunit/block-supports/layout-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,88 @@ public function data_gutenberg_get_layout_style() {
),
);
}

/**
* Check that gutenberg_render_layout_support_flag() renders the correct classnames on the wrapper.
*
* @dataProvider data_layout_support_flag_renders_classnames_on_wrapper
*
* @covers ::gutenberg_render_layout_support_flag
*
* @param array $args Dataset to test.
* @param string $expected_output The expected output.
*/
public function test_layout_support_flag_renders_classnames_on_wrapper( $args, $expected_output ) {
$actual_output = gutenberg_render_layout_support_flag( $args['block_content'], $args['block'] );
$this->assertEquals( $expected_output, $actual_output );
}

/**
* Data provider for test_layout_support_flag_renders_classnames_on_wrapper.
*
* @return array
*/
public function data_layout_support_flag_renders_classnames_on_wrapper() {
return array(
'single wrapper block layout with flow type' => 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 is-layout-flow"></div>',
),
'single wrapper block layout with constrained type' => array(
'args' => array(
'block_content' => '<div class="wp-block-group"></div>',
'block' => array(
'blockName' => 'core/group',
'attrs' => array(
'layout' => array(
'type' => 'constrained',
),
),
'innerBlocks' => array(),
'innerHTML' => '<div class="wp-block-group"></div>',
'innerContent' => array(
'<div class="wp-block-group"></div>',
),
),
),
'expected_output' => '<div class="wp-block-group is-layout-constrained"></div>',
),
'multiple wrapper block layout with flow type' => array(
'args' => array(
'block_content' => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper"></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-wrapper"></div></div>',
'innerContent' => array(
'<div class="wp-block-group"><div class="wp-block-group__inner-wrapper">',
' ',
' </div></div>',
),
),
),
'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper is-layout-flow"></div></div>',
),
);
}
}

1 comment on commit c5104af

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in c5104af.
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/4098804623
📝 Reported issues:

Please sign in to comment.