Changeset 52261
- Timestamp:
- 11/28/2021 01:51:23 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-styles-registry.php
r52236 r52261 59 59 __( 'Block style name must be a string.' ), 60 60 '5.3.0' 61 ); 62 return false; 63 } 64 65 if ( str_contains( $style_properties['name'], ' ' ) ) { 66 _doing_it_wrong( 67 __METHOD__, 68 __( 'Block style name must not contain any spaces.' ), 69 '5.9.0' 61 70 ); 62 71 return false; -
trunk/tests/phpunit/tests/blocks/register.php
r52010 r52261 9 9 10 10 /** 11 * Tests for register_block_type(), unregister_block_type(), get_dynamic_block_names() .11 * Tests for register_block_type(), unregister_block_type(), get_dynamic_block_names() and register_block_style(). 12 12 * 13 13 * @since 5.0.0 … … 560 560 $this->assertSame( 3, $result->api_version ); 561 561 } 562 563 /** 564 * Test case to validate `_doing_it_wrong()` when block style name attribute 565 * contains one or more spaces. 566 * 567 * @dataProvider data_register_block_style_name_contain_spaces 568 * 569 * @ticket 54296 570 * 571 * @covers ::register_block_style 572 * 573 * @expectedIncorrectUsage WP_Block_Styles_Registry::register 574 * @param array $block_styles Array of block styles to test. 575 */ 576 public function test_register_block_style_name_contain_spaces( array $block_styles ) { 577 register_block_style( 'core/query', $block_styles ); 578 } 579 580 /** 581 * Data provider. 582 * 583 * @return array 584 */ 585 public function data_register_block_style_name_contain_spaces() { 586 return array( 587 'multiple spaces' => array( 588 array( 589 'name' => 'style-class-1 style-class-2', 590 'label' => 'Custom Style Label', 591 ), 592 ), 593 'single space' => array( 594 array( 595 'name' => 'style-class-1 style-class-2', 596 'label' => 'Custom Style Label', 597 ), 598 ), 599 ); 600 } 601 602 /** 603 * Test case to validate no `_doing_it_wrong()` happens when there is 604 * no empty space. 605 * 606 * @ticket 54296 607 * 608 * @covers ::register_block_style 609 */ 610 public function test_register_block_style_name_without_spaces() { 611 $block_styles = array( 612 'name' => 'style-class-1', 613 'label' => 'Custom Style Label', 614 ); 615 616 $actual = register_block_style( 'core/query', $block_styles ); 617 $this->assertTrue( $actual ); 618 } 562 619 }
Note: See TracChangeset
for help on using the changeset viewer.