Changeset 58801 for trunk/tests/phpunit/tests/blocks/register.php
- Timestamp:
- 07/24/2024 02:09:58 PM (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/register.php
r57987 r58801 959 959 960 960 /** 961 * Tests registering a block with variations from a PHP file. 962 * 963 * @ticket 61280 964 * 965 * @covers ::register_block_type_from_metadata 966 */ 967 public function test_register_block_type_from_metadata_with_variations_php_file() { 968 $filter_metadata_registration = static function ( $metadata ) { 969 $metadata['variations'] = 'file:./variations.php'; 970 return $metadata; 971 }; 972 973 add_filter( 'block_type_metadata', $filter_metadata_registration, 10, 2 ); 974 $result = register_block_type_from_metadata( 975 DIR_TESTDATA . '/blocks/notice' 976 ); 977 remove_filter( 'block_type_metadata', $filter_metadata_registration ); 978 979 $this->assertInstanceOf( 'WP_Block_Type', $result, 'The block was not registered' ); 980 981 $this->assertIsCallable( $result->variation_callback, 'The variation callback hasn\'t been set' ); 982 $expected_variations = require DIR_TESTDATA . '/blocks/notice/variations.php'; 983 $this->assertSame( 984 $expected_variations, 985 call_user_func( $result->variation_callback ), 986 'The variation callback hasn\'t been set correctly' 987 ); 988 $this->assertSame( $expected_variations, $result->variations, 'The block variations are incorrect' ); 989 } 990 991 /** 961 992 * Tests that the function returns the registered block when the `block.json` 962 993 * is found in the fixtures directory.
Note: See TracChangeset
for help on using the changeset viewer.