Changeset 58170 for trunk/tests/phpunit/tests/block-supports/layout.php
- Timestamp:
- 05/18/2024 08:30:57 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-supports/layout.php
r57328 r58170 173 173 * @ticket 58548 174 174 * @ticket 60292 175 * @ticket 61111 175 176 * 176 177 * @dataProvider data_layout_support_flag_renders_classnames_on_wrapper … … 182 183 */ 183 184 public function test_layout_support_flag_renders_classnames_on_wrapper( $args, $expected_output ) { 185 switch_theme( 'default' ); 184 186 $actual_output = wp_render_layout_support_flag( $args['block_content'], $args['block'] ); 185 187 $this->assertSame( $expected_output, $actual_output ); … … 251 253 ), 252 254 'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper is-layout-flow wp-block-group-is-layout-flow"></div></div>', 255 ), 256 'block with child layout' => array( 257 'args' => array( 258 'block_content' => '<p>Some text.</p>', 259 'block' => array( 260 'blockName' => 'core/paragraph', 261 'attrs' => array( 262 'style' => array( 263 'layout' => array( 264 'columnSpan' => '2', 265 ), 266 ), 267 ), 268 'innerBlocks' => array(), 269 'innerHTML' => '<p>Some text.</p>', 270 'innerContent' => array( 271 '<p>Some text.</p>', 272 ), 273 ), 274 ), 275 'expected_output' => '<p class="wp-container-content-1">Some text.</p>', // The generated classname number assumes `wp_unique_prefixed_id( 'wp-container-content-' )` will not have run previously in this test. 253 276 ), 254 277 'skip classname output if block does not support layout and there are no child layout classes to be output' => array( … … 363 386 ); 364 387 } 388 389 /** 390 * Checks that `wp_add_parent_layout_to_parsed_block` adds the parent layout attribute to the block object. 391 * 392 * @ticket 61111 393 * 394 * @covers ::wp_add_parent_layout_to_parsed_block 395 * 396 * @dataProvider data_wp_add_parent_layout_to_parsed_block 397 * 398 * @param array $block The block object. 399 * @param WP_Block $parent_block The parent block object. 400 * @param array $expected The expected block object. 401 */ 402 public function test_wp_add_parent_layout_to_parsed_block( $block, $parent_block, $expected ) { 403 $actual = wp_add_parent_layout_to_parsed_block( $block, array(), $parent_block ); 404 $this->assertSame( $expected, $actual ); 405 } 406 407 /** 408 * Data provider for test_wp_add_parent_layout_to_parsed_block. 409 * 410 * @return array 411 */ 412 public function data_wp_add_parent_layout_to_parsed_block() { 413 return array( 414 'block with no parent layout' => array( 415 'block' => array( 416 'blockName' => 'core/group', 417 'attrs' => array( 418 'layout' => array( 419 'type' => 'default', 420 ), 421 ), 422 ), 423 'parent_block' => array(), 424 'expected' => array( 425 'blockName' => 'core/group', 426 'attrs' => array( 427 'layout' => array( 428 'type' => 'default', 429 ), 430 ), 431 ), 432 ), 433 'block with parent layout' => array( 434 'block' => array( 435 'blockName' => 'core/group', 436 'attrs' => array( 437 'layout' => array( 438 'type' => 'default', 439 ), 440 ), 441 ), 442 'parent_block' => new WP_Block( 443 array( 444 'attrs' => array( 445 'layout' => array( 446 'type' => 'grid', 447 ), 448 ), 449 ) 450 ), 451 'expected' => array( 452 'blockName' => 'core/group', 453 'attrs' => array( 454 'layout' => array( 455 'type' => 'default', 456 ), 457 ), 458 'parentLayout' => array( 459 'type' => 'grid', 460 ), 461 ), 462 ), 463 ); 464 } 365 465 }
Note: See TracChangeset
for help on using the changeset viewer.