Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 15 additions & 34 deletions tests/phpunit/tests/blocks/wpBlockTypeRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @since 5.0.0
*
* @group blocks
*
* @covers WP_Block_Type_Registry
*/
class Tests_Blocks_wpBlockTypeRegistry extends WP_UnitTestCase {

Expand Down Expand Up @@ -41,51 +43,30 @@ public function tear_down() {
}

/**
* Should reject numbers
*
* @ticket 45097
*
* @expectedIncorrectUsage WP_Block_Type_Registry::register
*/
public function test_invalid_non_string_names() {
$result = $this->registry->register( 1, array() );
$this->assertFalse( $result );
}

/**
* Should reject blocks without a namespace
*
* @ticket 45097
*
* @expectedIncorrectUsage WP_Block_Type_Registry::register
*/
public function test_invalid_names_without_namespace() {
$result = $this->registry->register( 'paragraph', array() );
$this->assertFalse( $result );
}

/**
* Should reject blocks with invalid characters
* Should reject invalid block names.
*
* @ticket 45097
*
* @dataProvider data_invalid_block_names
* @expectedIncorrectUsage WP_Block_Type_Registry::register
*/
public function test_invalid_characters() {
$result = $this->registry->register( 'still/_doing_it_wrong', array() );
public function test_invalid_block_names( $name ) {
$result = $this->registry->register( $name, array() );
$this->assertFalse( $result );
}

/**
* Should reject blocks with uppercase characters
*
* @ticket 45097
* Data provider for test_invalid_block_names().
*
* @expectedIncorrectUsage WP_Block_Type_Registry::register
* @return array<string, array{ 0: mixed }>
*/
public function test_uppercase_characters() {
$result = $this->registry->register( 'Core/Paragraph', array() );
$this->assertFalse( $result );
public function data_invalid_block_names(): array {
return array(
'non-string name' => array( 1 ),
'no namespace' => array( 'paragraph' ),
'invalid characters' => array( 'still/_doing_it_wrong' ),
'uppercase characters' => array( 'Core/Paragraph' ),
);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/tests/rewrite/addRewriteEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/**
* @group rewrite
*
* @covers ::add_rewrite_endpoint
*/
class Tests_Rewrite_AddRewriteEndpoint extends WP_UnitTestCase {
private $qvs;
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/tests/rewrite/addRewriteRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/**
* @group rewrite
*
* @covers ::add_rewrite_rule
*/
class Tests_Rewrite_AddRewriteRule extends WP_UnitTestCase {

Expand Down
Loading