|
7 | 7 | * @since 5.0.0 |
8 | 8 | * |
9 | 9 | * @group blocks |
| 10 | + * |
| 11 | + * @covers WP_Block_Type_Registry |
10 | 12 | */ |
11 | 13 | class Tests_Blocks_wpBlockTypeRegistry extends WP_UnitTestCase { |
12 | 14 |
|
@@ -41,51 +43,30 @@ public function tear_down() { |
41 | 43 | } |
42 | 44 |
|
43 | 45 | /** |
44 | | - * Should reject numbers |
45 | | - * |
46 | | - * @ticket 45097 |
47 | | - * |
48 | | - * @expectedIncorrectUsage WP_Block_Type_Registry::register |
49 | | - */ |
50 | | - public function test_invalid_non_string_names() { |
51 | | - $result = $this->registry->register( 1, array() ); |
52 | | - $this->assertFalse( $result ); |
53 | | - } |
54 | | - |
55 | | - /** |
56 | | - * Should reject blocks without a namespace |
57 | | - * |
58 | | - * @ticket 45097 |
59 | | - * |
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 |
| 46 | + * Should reject invalid block names. |
69 | 47 | * |
70 | 48 | * @ticket 45097 |
71 | 49 | * |
| 50 | + * @dataProvider data_invalid_block_names |
72 | 51 | * @expectedIncorrectUsage WP_Block_Type_Registry::register |
73 | 52 | */ |
74 | | - public function test_invalid_characters() { |
75 | | - $result = $this->registry->register( 'still/_doing_it_wrong', array() ); |
| 53 | + public function test_invalid_block_names( $name ) { |
| 54 | + $result = $this->registry->register( $name, array() ); |
76 | 55 | $this->assertFalse( $result ); |
77 | 56 | } |
78 | 57 |
|
79 | 58 | /** |
80 | | - * Should reject blocks with uppercase characters |
81 | | - * |
82 | | - * @ticket 45097 |
| 59 | + * Data provider for test_invalid_block_names(). |
83 | 60 | * |
84 | | - * @expectedIncorrectUsage WP_Block_Type_Registry::register |
| 61 | + * @return array<string, array{ 0: mixed }> |
85 | 62 | */ |
86 | | - public function test_uppercase_characters() { |
87 | | - $result = $this->registry->register( 'Core/Paragraph', array() ); |
88 | | - $this->assertFalse( $result ); |
| 63 | + public function data_invalid_block_names(): array { |
| 64 | + return array( |
| 65 | + 'non-string name' => array( 1 ), |
| 66 | + 'no namespace' => array( 'paragraph' ), |
| 67 | + 'invalid characters' => array( 'still/_doing_it_wrong' ), |
| 68 | + 'uppercase characters' => array( 'Core/Paragraph' ), |
| 69 | + ); |
89 | 70 | } |
90 | 71 |
|
91 | 72 | /** |
|
0 commit comments