| | 879 | /** |
| | 880 | * Tests registering a block with a 'style' attribute using arguments instead of block.json. |
| | 881 | * |
| | 882 | * @ticket XXXXX |
| | 883 | * |
| | 884 | * @covers ::register_block_type_from_metadata |
| | 885 | */ |
| | 886 | public function test_register_block_type_from_metadata_with_style_attribute() { |
| | 887 | $warnings = []; |
| | 888 | set_error_handler( |
| | 889 | function( $errno, $errstr ) use ( &$warnings ) { |
| | 890 | $warnings[] = $errstr; |
| | 891 | }, |
| | 892 | E_WARNING |
| | 893 | ); |
| | 894 | |
| | 895 | $result = register_block_type_from_metadata( |
| | 896 | '', |
| | 897 | array( |
| | 898 | 'api_version' => 2, |
| | 899 | 'name' => 'tests/notice-with-style', |
| | 900 | 'title' => 'Notice with style', |
| | 901 | 'category' => 'common', |
| | 902 | 'icon' => 'star', |
| | 903 | 'description' => 'Test block with style attribute', |
| | 904 | 'keywords' => array('test', 'style'), |
| | 905 | 'textdomain' => 'notice-with-style', |
| | 906 | 'style' => array('wc-blocks-style', 'wc-blocks-style-active-filters'), |
| | 907 | ) |
| | 908 | ); |
| | 909 | |
| | 910 | // Restore normal error handling |
| | 911 | restore_error_handler(); |
| | 912 | |
| | 913 | // Assert that the block was registered successfully |
| | 914 | $this->assertInstanceOf( 'WP_Block_Type', $result, 'The block was not registered' ); |
| | 915 | |
| | 916 | // Check for any warnings |
| | 917 | $this->assertEmpty( $warnings, 'Unexpected warnings were generated during block registration' ); |
| | 918 | } |
| | 919 | |