From 08d48cb4d8a687d894b29327f8ce4d443273e63b Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 3 Oct 2025 11:54:52 +0530 Subject: [PATCH 01/17] Update is_registered method to handle null template name --- src/wp-includes/class-wp-block-templates-registry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-block-templates-registry.php b/src/wp-includes/class-wp-block-templates-registry.php index 1a1c259dba1dc..966eb1e65bfc7 100644 --- a/src/wp-includes/class-wp-block-templates-registry.php +++ b/src/wp-includes/class-wp-block-templates-registry.php @@ -204,11 +204,11 @@ public function get_by_query( $query = array() ) { * * @since 6.7.0 * - * @param string $template_name Template name. + * @param string|null $template_name Template name. * @return bool True if the template is registered, false otherwise. */ public function is_registered( $template_name ) { - return isset( $this->registered_templates[ $template_name ] ); + return isset( $template_name, $this->registered_templates[ $template_name ] ); } /** From 92aecfb59b5879d7b467a5979d20d58ea46615ca Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 3 Oct 2025 11:56:15 +0530 Subject: [PATCH 02/17] Update class-wp-block-bindings-registry.php --- src/wp-includes/class-wp-block-bindings-registry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-block-bindings-registry.php b/src/wp-includes/class-wp-block-bindings-registry.php index dc065356c5ce4..f372a1e7fdcb5 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -249,11 +249,11 @@ public function get_registered( string $source_name ) { * * @since 6.5.0 * - * @param string $source_name The name of the source. + * @param string| $source_name The name of the source. * @return bool `true` if the block bindings source is registered, `false` otherwise. */ public function is_registered( $source_name ) { - return isset( $this->sources[ $source_name ] ); + return isset( $source_name, $this->sources[ $source_name ] ); } /** From f0a625117bea269eeab427511d42dd86ac963b5c Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 3 Oct 2025 11:57:24 +0530 Subject: [PATCH 03/17] Update class-wp-block-pattern-categories-registry.php --- .../class-wp-block-pattern-categories-registry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-block-pattern-categories-registry.php b/src/wp-includes/class-wp-block-pattern-categories-registry.php index 2d5fbcf2fe10f..05ddce8af0547 100644 --- a/src/wp-includes/class-wp-block-pattern-categories-registry.php +++ b/src/wp-includes/class-wp-block-pattern-categories-registry.php @@ -138,11 +138,11 @@ public function get_all_registered( $outside_init_only = false ) { * * @since 5.5.0 * - * @param string $category_name Pattern category name including namespace. + * @param string|null $category_name Pattern category name including namespace. * @return bool True if the pattern category is registered, false otherwise. */ public function is_registered( $category_name ) { - return isset( $this->registered_categories[ $category_name ] ); + return isset( $category_name, $this->registered_categories[ $category_name ] ); } /** From 9afab593acc5d6c0d54c9cf9b6f1a8f3591fd2cb Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 3 Oct 2025 11:58:39 +0530 Subject: [PATCH 04/17] Change pattern_name parameter to nullable string Update parameter type hint for is_registered method. --- src/wp-includes/class-wp-block-patterns-registry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-block-patterns-registry.php b/src/wp-includes/class-wp-block-patterns-registry.php index 2afa8a853f1b9..4667979fc72b5 100644 --- a/src/wp-includes/class-wp-block-patterns-registry.php +++ b/src/wp-includes/class-wp-block-patterns-registry.php @@ -238,11 +238,11 @@ public function get_all_registered( $outside_init_only = false ) { * * @since 5.5.0 * - * @param string $pattern_name Block pattern name including namespace. + * @param string|null $pattern_name Block pattern name including namespace. * @return bool True if the pattern is registered, false otherwise. */ public function is_registered( $pattern_name ) { - return isset( $this->registered_patterns[ $pattern_name ] ); + return isset( $pattern_name, $this->registered_patterns[ $pattern_name ] ); } public function __wakeup() { From 4549185a80fd25ebf569a32cb69adf982e345c60 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 3 Oct 2025 11:59:49 +0530 Subject: [PATCH 05/17] Update parameter types in is_registered method --- src/wp-includes/class-wp-block-styles-registry.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-block-styles-registry.php b/src/wp-includes/class-wp-block-styles-registry.php index 8fb5e2eb23820..60c799898580a 100644 --- a/src/wp-includes/class-wp-block-styles-registry.php +++ b/src/wp-includes/class-wp-block-styles-registry.php @@ -181,12 +181,12 @@ public function get_registered_styles_for_block( $block_name ) { * * @since 5.3.0 * - * @param string $block_name Block type name including namespace. - * @param string $block_style_name Block style name. + * @param string|null $block_name Block type name including namespace. + * @param string|null $block_style_name Block style name. * @return bool True if the block style is registered, false otherwise. */ public function is_registered( $block_name, $block_style_name ) { - return isset( $this->registered_block_styles[ $block_name ][ $block_style_name ] ); + return isset( $block_name, $block_style_name, $this->registered_block_styles[ $block_name ][ $block_style_name ] ); } /** From fbdd678099acdaa3a147df78cc34046c0e74d060 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 3 Oct 2025 12:01:02 +0530 Subject: [PATCH 06/17] Fix parameter type hint in is_registered method --- src/wp-includes/class-wp-block-bindings-registry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-block-bindings-registry.php b/src/wp-includes/class-wp-block-bindings-registry.php index f372a1e7fdcb5..519453d22ba92 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -249,7 +249,7 @@ public function get_registered( string $source_name ) { * * @since 6.5.0 * - * @param string| $source_name The name of the source. + * @param string|null $source_name The name of the source. * @return bool `true` if the block bindings source is registered, `false` otherwise. */ public function is_registered( $source_name ) { From 7a6617c07a4a81816020fcdce1f72896b6746089 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 09:20:16 +0530 Subject: [PATCH 07/17] Apply suggestions from code review --- src/wp-includes/class-wp-block-styles-registry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-block-styles-registry.php b/src/wp-includes/class-wp-block-styles-registry.php index 60c799898580a..18b5152aac792 100644 --- a/src/wp-includes/class-wp-block-styles-registry.php +++ b/src/wp-includes/class-wp-block-styles-registry.php @@ -186,7 +186,7 @@ public function get_registered_styles_for_block( $block_name ) { * @return bool True if the block style is registered, false otherwise. */ public function is_registered( $block_name, $block_style_name ) { - return isset( $block_name, $block_style_name, $this->registered_block_styles[ $block_name ][ $block_style_name ] ); + return isset( $block_name, $this->registered_block_styles[ $block_name ][ $block_style_name ] ); } /** From 73b7df3747636b55b3cc0dc24e005b2b5ffcaafb Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 09:26:54 +0530 Subject: [PATCH 08/17] Add test for empty source name registration Add test for is_registered method with empty source name --- .../tests/block-bindings/wpBlockBindingsRegistry.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php b/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php index 9beebaa2c3108..e2224c3eef2d9 100644 --- a/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php +++ b/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php @@ -344,4 +344,16 @@ public function test_is_registered_for_known_source() { $result = $this->registry->is_registered( self::$test_source_name ); $this->assertTrue( $result ); } + + /** + * Should return false when checking registration with an empty source name. + * + * @ticket 63957 + * + * @covers WP_Block_Bindings_Registry::is_registered + */ + public function test_is_registered_with_empty_source_name() { + $result = $this->registry->is_registered( '' ); + $this->assertFalse( $result ); + } } From 0ea22bff2dff9cccc64c55005717cf9eb782dbe5 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 10:24:57 +0530 Subject: [PATCH 09/17] Add unit tests for WP_Block_Pattern_Categories_Registry::is_registered() --- .../wpBlockPatternCategoriesRegistry.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php diff --git a/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php new file mode 100644 index 0000000000000..459c77d528ae3 --- /dev/null +++ b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php @@ -0,0 +1,33 @@ +assertFalse( $registry->is_registered( '' ) ); + + // Should return false when called with null. + $this->assertFalse( $registry->is_registered( null ) ); + + // Should return false when called with false. + $this->assertFalse( $registry->is_registered( false ) ); + + // Should return false when called with 0. + $this->assertFalse( $registry->is_registered( 0 ) ); + } +} From 5ad86261f7e28f7642f45f9afa49fedaf2785fe3 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 10:42:37 +0530 Subject: [PATCH 10/17] Add tests for WP_Block_Patterns_Registry methods --- .../block-pattern/wpBlockPatternsRegistry.php | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php diff --git a/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php b/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php new file mode 100644 index 0000000000000..a242b03cf43f6 --- /dev/null +++ b/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php @@ -0,0 +1,81 @@ +registry = WP_Block_Patterns_Registry::get_instance(); + } + + public function tear_down() { + $this->registry = null; + + parent::tear_down(); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_unregistered_pattern() { + $this->assertFalse( $this->registry->is_registered( 'my/pattern' ) ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_true_for_registered_pattern() { + $this->registry->register( + 'my/pattern', + array( + 'title' => 'My Pattern', + 'content' => '

Test

', + ) + ); + + $this->assertTrue( $this->registry->is_registered( 'my/pattern' ) ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_after_unregistering_pattern() { + $this->registry->register( + 'my/pattern', + array( + 'title' => 'My Pattern', + 'content' => '

Test

', + ) + ); + + $this->registry->unregister( 'my/pattern' ); + + $this->assertFalse( $this->registry->is_registered( 'my/pattern' ) ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_with_invalid_pattern_name() { + $this->assertFalse( $this->registry->is_registered( '' ) ); + $this->assertFalse( $this->registry->is_registered( null ) ); + $this->assertFalse( $this->registry->is_registered( false ) ); + $this->assertFalse( $this->registry->is_registered( 0 ) ); + } +} From 9fed959bf6e6e490320c7061396726d233af2e04 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 11:32:43 +0530 Subject: [PATCH 11/17] Add unit tests for WP_Block_Styles_Registry::is_registered This file contains unit tests for the WP_Block_Styles_Registry class, specifically testing the is_registered() method with various scenarios. --- .../block-styles/wpBlockStylesRegistry.php | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php diff --git a/tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php b/tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php new file mode 100644 index 0000000000000..7b5fc195f3e89 --- /dev/null +++ b/tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php @@ -0,0 +1,137 @@ +registry = WP_Block_Styles_Registry::get_instance(); + } + + public function tearDown(): void { + $this->registry = null; + parent::tearDown(); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_unregistered_style() { + $this->assertFalse( + $this->registry->is_registered( 'core/paragraph', 'fancy-style' ), + 'Unregistered style should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_true_for_registered_style() { + $block_name = 'core/paragraph'; + $style_name = 'fancy-style'; + + $this->registry->register( + $block_name, + array( + 'name' => $style_name, + 'label' => 'Fancy Style', + ) + ); + + $this->assertTrue( + $this->registry->is_registered( $block_name, $style_name ), + 'Registered style should return true.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_wrong_block() { + $block_name = 'core/paragraph'; + $style_name = 'fancy-style'; + + $this->registry->register( + $block_name, + array( + 'name' => $style_name, + 'label' => 'Fancy Style', + ) + ); + + $this->assertFalse( + $this->registry->is_registered( 'core/image', $style_name ), + 'Style registered for another block should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_wrong_style_name() { + $block_name = 'core/paragraph'; + $style_name = 'fancy-style'; + + $this->registry->register( + $block_name, + array( + 'name' => $style_name, + 'label' => 'Fancy Style', + ) + ); + + $this->assertFalse( + $this->registry->is_registered( $block_name, 'other-style' ), + 'Non-existent style name should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_empty_block_name() { + $style_name = 'fancy-style'; + $this->assertFalse( + $this->registry->is_registered( '', $style_name ), + 'Empty block name should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_empty_style_name() { + $block_name = 'core/paragraph'; + $this->assertFalse( + $this->registry->is_registered( $block_name, '' ), + 'Empty style name should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_both_empty_params() { + $this->assertFalse( + $this->registry->is_registered( '', '' ), + 'Both empty block and style name should return false.' + ); + } +} From 11d25ce5b48ab83bfeede7a6aeb9847023b9a787 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 12:30:00 +0530 Subject: [PATCH 12/17] Update WpBlockTemplatesRegistry.php --- .../tests/block-templates/WpBlockTemplatesRegistry.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php b/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php index a2b1d16eef618..503f36cb6fdc9 100644 --- a/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php +++ b/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php @@ -247,6 +247,16 @@ public function test_is_registered() { self::$registry->unregister( $template_name ); } + /** + * @ticket 63957 + * + * @covers ::is_registered + */ + public function test_is_registered_with_invalid_param() { + $this->assertFalse( self::$registry->is_registered( '' ) ); + $this->assertFalse( self::$registry->is_registered( null ) ); + } + /** * Tests that unregister() correctly unregisters a registered template. * From 5581a4761d632a7067f5c775844694f2f4953aa0 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 12:41:55 +0530 Subject: [PATCH 13/17] Remove bool check --- .../block-pattern/wpBlockPatternCategoriesRegistry.php | 9 --------- .../tests/block-pattern/wpBlockPatternsRegistry.php | 2 -- 2 files changed, 11 deletions(-) diff --git a/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php index 459c77d528ae3..f7e1ad88a8061 100644 --- a/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php +++ b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php @@ -18,16 +18,7 @@ class Tests_Block_Pattern_WPBlockPatternCategoriesRegistry extends WP_UnitTestCa public function test_is_registered_with_empty_param() { $registry = WP_Block_Pattern_Categories_Registry::get_instance(); - // Should return false when called with empty string. $this->assertFalse( $registry->is_registered( '' ) ); - - // Should return false when called with null. $this->assertFalse( $registry->is_registered( null ) ); - - // Should return false when called with false. - $this->assertFalse( $registry->is_registered( false ) ); - - // Should return false when called with 0. - $this->assertFalse( $registry->is_registered( 0 ) ); } } diff --git a/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php b/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php index a242b03cf43f6..1f66824330a8e 100644 --- a/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php +++ b/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php @@ -75,7 +75,5 @@ public function test_is_registered_returns_false_after_unregistering_pattern() { public function test_is_registered_with_invalid_pattern_name() { $this->assertFalse( $this->registry->is_registered( '' ) ); $this->assertFalse( $this->registry->is_registered( null ) ); - $this->assertFalse( $this->registry->is_registered( false ) ); - $this->assertFalse( $this->registry->is_registered( 0 ) ); } } From 4a066b89e8799f5bc81d12bd13350d8dd32ee235 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 12:48:19 +0530 Subject: [PATCH 14/17] Run unit tests against PHP 8.5 --- .github/workflows/phpunit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index ccd52008928a2..ddcf942346917 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -72,7 +72,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-24.04 ] - php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] + php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] db-type: [ 'mysql' ] db-version: [ '5.7', '8.0', '8.4' ] tests-domain: [ 'example.org' ] From 1d4704379123662ee9233fba681e8a1e26b0dfcf Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 14:16:01 +0530 Subject: [PATCH 15/17] Check for null param --- src/wp-includes/class-wp-block-styles-registry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-block-styles-registry.php b/src/wp-includes/class-wp-block-styles-registry.php index 18b5152aac792..60c799898580a 100644 --- a/src/wp-includes/class-wp-block-styles-registry.php +++ b/src/wp-includes/class-wp-block-styles-registry.php @@ -186,7 +186,7 @@ public function get_registered_styles_for_block( $block_name ) { * @return bool True if the block style is registered, false otherwise. */ public function is_registered( $block_name, $block_style_name ) { - return isset( $block_name, $this->registered_block_styles[ $block_name ][ $block_style_name ] ); + return isset( $block_name, $block_style_name, $this->registered_block_styles[ $block_name ][ $block_style_name ] ); } /** From 7165f9b0d2756a79ed8ecae4641d74751188e5b8 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 15:22:02 +0530 Subject: [PATCH 16/17] Move tests --- .../block-pattern/wpBlockPatternsRegistry.php | 79 ---------- .../block-styles/wpBlockStylesRegistry.php | 137 ------------------ .../tests/blocks/wpBlockPatternsRegistry.php | 8 + .../tests/blocks/wpBlockStylesRegistry.php | 32 ++++ 4 files changed, 40 insertions(+), 216 deletions(-) delete mode 100644 tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php delete mode 100644 tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php diff --git a/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php b/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php deleted file mode 100644 index 1f66824330a8e..0000000000000 --- a/tests/phpunit/tests/block-pattern/wpBlockPatternsRegistry.php +++ /dev/null @@ -1,79 +0,0 @@ -registry = WP_Block_Patterns_Registry::get_instance(); - } - - public function tear_down() { - $this->registry = null; - - parent::tear_down(); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_for_unregistered_pattern() { - $this->assertFalse( $this->registry->is_registered( 'my/pattern' ) ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_true_for_registered_pattern() { - $this->registry->register( - 'my/pattern', - array( - 'title' => 'My Pattern', - 'content' => '

Test

', - ) - ); - - $this->assertTrue( $this->registry->is_registered( 'my/pattern' ) ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_after_unregistering_pattern() { - $this->registry->register( - 'my/pattern', - array( - 'title' => 'My Pattern', - 'content' => '

Test

', - ) - ); - - $this->registry->unregister( 'my/pattern' ); - - $this->assertFalse( $this->registry->is_registered( 'my/pattern' ) ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_with_invalid_pattern_name() { - $this->assertFalse( $this->registry->is_registered( '' ) ); - $this->assertFalse( $this->registry->is_registered( null ) ); - } -} diff --git a/tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php b/tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php deleted file mode 100644 index 7b5fc195f3e89..0000000000000 --- a/tests/phpunit/tests/block-styles/wpBlockStylesRegistry.php +++ /dev/null @@ -1,137 +0,0 @@ -registry = WP_Block_Styles_Registry::get_instance(); - } - - public function tearDown(): void { - $this->registry = null; - parent::tearDown(); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_for_unregistered_style() { - $this->assertFalse( - $this->registry->is_registered( 'core/paragraph', 'fancy-style' ), - 'Unregistered style should return false.' - ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_true_for_registered_style() { - $block_name = 'core/paragraph'; - $style_name = 'fancy-style'; - - $this->registry->register( - $block_name, - array( - 'name' => $style_name, - 'label' => 'Fancy Style', - ) - ); - - $this->assertTrue( - $this->registry->is_registered( $block_name, $style_name ), - 'Registered style should return true.' - ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_for_wrong_block() { - $block_name = 'core/paragraph'; - $style_name = 'fancy-style'; - - $this->registry->register( - $block_name, - array( - 'name' => $style_name, - 'label' => 'Fancy Style', - ) - ); - - $this->assertFalse( - $this->registry->is_registered( 'core/image', $style_name ), - 'Style registered for another block should return false.' - ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_for_wrong_style_name() { - $block_name = 'core/paragraph'; - $style_name = 'fancy-style'; - - $this->registry->register( - $block_name, - array( - 'name' => $style_name, - 'label' => 'Fancy Style', - ) - ); - - $this->assertFalse( - $this->registry->is_registered( $block_name, 'other-style' ), - 'Non-existent style name should return false.' - ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_for_empty_block_name() { - $style_name = 'fancy-style'; - $this->assertFalse( - $this->registry->is_registered( '', $style_name ), - 'Empty block name should return false.' - ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_for_empty_style_name() { - $block_name = 'core/paragraph'; - $this->assertFalse( - $this->registry->is_registered( $block_name, '' ), - 'Empty style name should return false.' - ); - } - - /** - * @ticket 63957 - */ - public function test_is_registered_returns_false_for_both_empty_params() { - $this->assertFalse( - $this->registry->is_registered( '', '' ), - 'Both empty block and style name should return false.' - ); - } -} diff --git a/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php b/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php index 378789c231b7f..834a475dc81ed 100644 --- a/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php +++ b/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php @@ -695,4 +695,12 @@ private function set_registered_patterns_variable_value( $value ) { $property->setAccessible( false ); } } + + /** + * @ticket 63957 + */ + public function test_is_registered_with_invalid_pattern_name() { + $this->assertFalse( $this->registry->is_registered( '' ) ); + $this->assertFalse( $this->registry->is_registered( null ) ); + } } diff --git a/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php b/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php index f73ba67ba1619..d91f134d2b099 100644 --- a/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php +++ b/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php @@ -66,4 +66,36 @@ public function test_register_block_style_with_array_of_block_names() { $this->assertTrue( $this->registry->is_registered( 'core/paragraph', 'plain' ) ); $this->assertTrue( $this->registry->is_registered( 'core/group', 'plain' ) ); } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_empty_block_name() { + $style_name = 'fancy-style'; + $this->assertFalse( + $this->registry->is_registered( '', $style_name ), + 'Empty block name should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_empty_style_name() { + $block_name = 'core/paragraph'; + $this->assertFalse( + $this->registry->is_registered( $block_name, '' ), + 'Empty style name should return false.' + ); + } + + /** + * @ticket 63957 + */ + public function test_is_registered_returns_false_for_both_empty_params() { + $this->assertFalse( + $this->registry->is_registered( '', '' ), + 'Both empty block and style name should return false.' + ); + } } From 7bc2cd29109a285d635a5c4348f8fe518e54c7f9 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 6 Oct 2025 15:34:50 +0530 Subject: [PATCH 17/17] Remove empty check --- .../tests/block-bindings/wpBlockBindingsRegistry.php | 6 +++--- .../wpBlockPatternCategoriesRegistry.php | 4 +--- .../block-templates/WpBlockTemplatesRegistry.php | 3 +-- .../phpunit/tests/blocks/wpBlockPatternsRegistry.php | 3 +-- tests/phpunit/tests/blocks/wpBlockStylesRegistry.php | 12 ++++++------ 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php b/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php index e2224c3eef2d9..9ea0933a9c299 100644 --- a/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php +++ b/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php @@ -346,14 +346,14 @@ public function test_is_registered_for_known_source() { } /** - * Should return false when checking registration with an empty source name. + * Should return false when checking registration with a null source name. * * @ticket 63957 * * @covers WP_Block_Bindings_Registry::is_registered */ - public function test_is_registered_with_empty_source_name() { - $result = $this->registry->is_registered( '' ); + public function test_is_registered_with_null_source_name() { + $result = $this->registry->is_registered( null ); $this->assertFalse( $result ); } } diff --git a/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php index f7e1ad88a8061..8a6700d69db41 100644 --- a/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php +++ b/tests/phpunit/tests/block-pattern/wpBlockPatternCategoriesRegistry.php @@ -15,10 +15,8 @@ class Tests_Block_Pattern_WPBlockPatternCategoriesRegistry extends WP_UnitTestCa /** * @ticket 63957 */ - public function test_is_registered_with_empty_param() { + public function test_is_registered_with_null_category_name() { $registry = WP_Block_Pattern_Categories_Registry::get_instance(); - - $this->assertFalse( $registry->is_registered( '' ) ); $this->assertFalse( $registry->is_registered( null ) ); } } diff --git a/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php b/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php index 503f36cb6fdc9..e4675ad210751 100644 --- a/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php +++ b/tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php @@ -252,8 +252,7 @@ public function test_is_registered() { * * @covers ::is_registered */ - public function test_is_registered_with_invalid_param() { - $this->assertFalse( self::$registry->is_registered( '' ) ); + public function test_is_registered_with_null_template_name() { $this->assertFalse( self::$registry->is_registered( null ) ); } diff --git a/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php b/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php index 834a475dc81ed..738d086f4a30e 100644 --- a/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php +++ b/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php @@ -699,8 +699,7 @@ private function set_registered_patterns_variable_value( $value ) { /** * @ticket 63957 */ - public function test_is_registered_with_invalid_pattern_name() { - $this->assertFalse( $this->registry->is_registered( '' ) ); + public function test_is_registered_with_null_pattern_name() { $this->assertFalse( $this->registry->is_registered( null ) ); } } diff --git a/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php b/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php index d91f134d2b099..6d3ff4e54a42e 100644 --- a/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php +++ b/tests/phpunit/tests/blocks/wpBlockStylesRegistry.php @@ -70,10 +70,10 @@ public function test_register_block_style_with_array_of_block_names() { /** * @ticket 63957 */ - public function test_is_registered_returns_false_for_empty_block_name() { + public function test_is_registered_returns_false_for_null_block_name() { $style_name = 'fancy-style'; $this->assertFalse( - $this->registry->is_registered( '', $style_name ), + $this->registry->is_registered( null, $style_name ), 'Empty block name should return false.' ); } @@ -81,10 +81,10 @@ public function test_is_registered_returns_false_for_empty_block_name() { /** * @ticket 63957 */ - public function test_is_registered_returns_false_for_empty_style_name() { + public function test_is_registered_returns_false_for_null_style_name() { $block_name = 'core/paragraph'; $this->assertFalse( - $this->registry->is_registered( $block_name, '' ), + $this->registry->is_registered( $block_name, null ), 'Empty style name should return false.' ); } @@ -92,9 +92,9 @@ public function test_is_registered_returns_false_for_empty_style_name() { /** * @ticket 63957 */ - public function test_is_registered_returns_false_for_both_empty_params() { + public function test_is_registered_returns_false_for_both_null_params() { $this->assertFalse( - $this->registry->is_registered( '', '' ), + $this->registry->is_registered( null, null ), 'Both empty block and style name should return false.' ); }