Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/class-wp-block-bindings-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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|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 ) {
return isset( $this->sources[ $source_name ] );
return isset( $source_name, $this->sources[ $source_name ] );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/class-wp-block-patterns-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/wp-includes/class-wp-block-styles-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/class-wp-block-templates-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 a null source name.
*
* @ticket 63957
*
* @covers WP_Block_Bindings_Registry::is_registered
*/
public function test_is_registered_with_null_source_name() {
$result = $this->registry->is_registered( null );
$this->assertFalse( $result );
}
Comment thread
mukeshpanchal27 marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Unit tests for WP_Block_Pattern_Categories_Registry::is_registered().
*
* @package WordPress
* @subpackage Blocks
* @since 6.9.0
*
* @group block-patterns
* @covers WP_Block_Pattern_Categories_Registry::is_registered
*/

class Tests_Block_Pattern_WPBlockPatternCategoriesRegistry extends WP_UnitTestCase {

/**
* @ticket 63957
*/
public function test_is_registered_with_null_category_name() {
$registry = WP_Block_Pattern_Categories_Registry::get_instance();
$this->assertFalse( $registry->is_registered( null ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ public function test_is_registered() {
self::$registry->unregister( $template_name );
}

/**
* @ticket 63957
*
* @covers ::is_registered
*/
public function test_is_registered_with_null_template_name() {
$this->assertFalse( self::$registry->is_registered( null ) );
}

/**
* Tests that unregister() correctly unregisters a registered template.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,4 +695,11 @@ private function set_registered_patterns_variable_value( $value ) {
$property->setAccessible( false );
}
}

/**
* @ticket 63957
*/
public function test_is_registered_with_null_pattern_name() {
$this->assertFalse( $this->registry->is_registered( null ) );
}
}
32 changes: 32 additions & 0 deletions tests/phpunit/tests/blocks/wpBlockStylesRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_null_block_name() {
$style_name = 'fancy-style';
$this->assertFalse(
$this->registry->is_registered( null, $style_name ),
'Empty block name should return false.'
);
}

/**
* @ticket 63957
*/
public function test_is_registered_returns_false_for_null_style_name() {
$block_name = 'core/paragraph';
$this->assertFalse(
$this->registry->is_registered( $block_name, null ),
'Empty style name should return false.'
);
}

/**
* @ticket 63957
*/
public function test_is_registered_returns_false_for_both_null_params() {
$this->assertFalse(
$this->registry->is_registered( null, null ),
'Both empty block and style name should return false.'
);
}
}
Loading