From 75aa87672edbf72eb1b7090d085e9f17173df470 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 3 Feb 2023 12:32:08 +1100 Subject: [PATCH] Add tests for gutenberg_render_layout_support_flag --- phpunit/block-supports/layout-test.php | 84 ++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/phpunit/block-supports/layout-test.php b/phpunit/block-supports/layout-test.php index c7e14ffe84dbc0..7ec06401c01706 100644 --- a/phpunit/block-supports/layout-test.php +++ b/phpunit/block-supports/layout-test.php @@ -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' => '
', + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => '
', + 'innerContent' => array( + '
', + ), + ), + ), + 'expected_output' => '
', + ), + 'single wrapper block layout with constrained type' => array( + 'args' => array( + 'block_content' => '
', + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'constrained', + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => '
', + 'innerContent' => array( + '
', + ), + ), + ), + 'expected_output' => '
', + ), + 'multiple wrapper block layout with flow type' => array( + 'args' => array( + 'block_content' => '
', + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => '
', + 'innerContent' => array( + '
', + ' ', + '
', + ), + ), + ), + 'expected_output' => '
', + ), + ); + } }