Skip to content

Commit 0025d1b

Browse files
Tests: Add missing @Covers tags and refactor invalid block name tests to use a data provider.
1 parent e12ddb3 commit 0025d1b

3 files changed

Lines changed: 19 additions & 34 deletions

File tree

tests/phpunit/tests/blocks/wpBlockTypeRegistry.php

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @since 5.0.0
88
*
99
* @group blocks
10+
*
11+
* @covers WP_Block_Type_Registry
1012
*/
1113
class Tests_Blocks_wpBlockTypeRegistry extends WP_UnitTestCase {
1214

@@ -41,51 +43,30 @@ public function tear_down() {
4143
}
4244

4345
/**
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.
6947
*
7048
* @ticket 45097
7149
*
50+
* @dataProvider data_invalid_block_names
7251
* @expectedIncorrectUsage WP_Block_Type_Registry::register
7352
*/
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() );
7655
$this->assertFalse( $result );
7756
}
7857

7958
/**
80-
* Should reject blocks with uppercase characters
81-
*
82-
* @ticket 45097
59+
* Data provider for test_invalid_block_names().
8360
*
84-
* @expectedIncorrectUsage WP_Block_Type_Registry::register
61+
* @return array<string, array{ 0: mixed }>
8562
*/
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+
);
8970
}
9071

9172
/**

tests/phpunit/tests/rewrite/addRewriteEndpoint.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/**
44
* @group rewrite
5+
*
6+
* @covers ::add_rewrite_endpoint
57
*/
68
class Tests_Rewrite_AddRewriteEndpoint extends WP_UnitTestCase {
79
private $qvs;

tests/phpunit/tests/rewrite/addRewriteRule.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/**
44
* @group rewrite
5+
*
6+
* @covers ::add_rewrite_rule
57
*/
68
class Tests_Rewrite_AddRewriteRule extends WP_UnitTestCase {
79

0 commit comments

Comments
 (0)