Changeset 62245
- Timestamp:
- 04/18/2026 04:45:54 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/wpBlockTypeRegistry.php
r55457 r62245 8 8 * 9 9 * @group blocks 10 * 11 * @coversDefaultClass WP_Block_Type_Registry 10 12 */ 11 13 class Tests_Blocks_wpBlockTypeRegistry extends WP_UnitTestCase { … … 42 44 43 45 /** 44 * Should reject numbers46 * Should reject invalid block names. 45 47 * 46 48 * @ticket 45097 47 49 * 50 * @covers ::register 51 * 52 * @dataProvider data_invalid_block_names 53 * 48 54 * @expectedIncorrectUsage WP_Block_Type_Registry::register 49 55 */ 50 public function test_invalid_ non_string_names() {51 $result = $this->registry->register( 1, array() );56 public function test_invalid_block_names( $name ) { 57 $result = $this->registry->register( $name, array() ); 52 58 $this->assertFalse( $result ); 53 59 } 54 60 55 61 /** 56 * Should reject blocks without a namespace 62 * Data provider for test_invalid_block_names(). 63 * 64 * @return array<string, array{ 0: mixed }> 65 */ 66 public function data_invalid_block_names(): array { 67 return array( 68 'non-string name' => array( 1 ), 69 'no namespace' => array( 'paragraph' ), 70 'invalid characters' => array( 'still/_doing_it_wrong' ), 71 'uppercase characters' => array( 'Core/Paragraph' ), 72 ); 73 } 74 75 /** 76 * Should accept valid block names. 57 77 * 58 78 * @ticket 45097 59 79 * 60 * @expectedIncorrectUsage WP_Block_Type_Registry::register 61 */ 62 public function test_invalid_names_without_namespace() { 63 $result = $this->registry->register( 'paragraph', array() ); 64 $this->assertFalse( $result ); 65 } 66 67 /** 68 * Should reject blocks with invalid characters 69 * 70 * @ticket 45097 71 * 72 * @expectedIncorrectUsage WP_Block_Type_Registry::register 73 */ 74 public function test_invalid_characters() { 75 $result = $this->registry->register( 'still/_doing_it_wrong', array() ); 76 $this->assertFalse( $result ); 77 } 78 79 /** 80 * Should reject blocks with uppercase characters 81 * 82 * @ticket 45097 83 * 84 * @expectedIncorrectUsage WP_Block_Type_Registry::register 85 */ 86 public function test_uppercase_characters() { 87 $result = $this->registry->register( 'Core/Paragraph', array() ); 88 $this->assertFalse( $result ); 89 } 90 91 /** 92 * Should accept valid block names 93 * 94 * @ticket 45097 80 * @covers ::register 81 * @covers ::get_registered 95 82 */ 96 83 public function test_register_block_type() { … … 107 94 108 95 /** 109 * Should fail to re-register the same block 96 * Should fail to re-register the same block. 110 97 * 111 98 * @ticket 45097 99 * 100 * @covers ::register 112 101 * 113 102 * @expectedIncorrectUsage WP_Block_Type_Registry::register … … 126 115 127 116 /** 128 * Should accept a WP_Block_Type instance 117 * Should accept a WP_Block_Type instance. 129 118 * 130 119 * @ticket 45097 120 * 121 * @covers ::register 131 122 */ 132 123 public function test_register_block_type_instance() { … … 138 129 139 130 /** 140 * Unregistering should fail if a block is not registered 131 * Unregistering should fail if a block is not registered. 141 132 * 142 133 * @ticket 45097 134 * 135 * @covers ::unregister 143 136 * 144 137 * @expectedIncorrectUsage WP_Block_Type_Registry::unregister … … 150 143 151 144 /** 152 * Should unregister existing blocks 145 * Should unregister existing blocks. 153 146 * 154 147 * @ticket 45097 148 * 149 * @covers ::unregister 150 * @covers ::is_registered 155 151 */ 156 152 public function test_unregister_block_type() { … … 169 165 /** 170 166 * @ticket 45097 167 * 168 * @covers ::get_all_registered 171 169 */ 172 170 public function test_get_all_registered() {
Note: See TracChangeset
for help on using the changeset viewer.