diff --git a/src/wp-includes/class-wp-block-type.php b/src/wp-includes/class-wp-block-type.php index b8ffb92e559b2..b783a80c4bd82 100644 --- a/src/wp-includes/class-wp-block-type.php +++ b/src/wp-includes/class-wp-block-type.php @@ -242,11 +242,13 @@ class WP_Block_Type { /** * Attributes supported by every block. * - * @since 6.0.0 + * @since 6.0.0 Added `lock`. + * @since 6.5.0 Added `metadata`. * @var array */ const GLOBAL_ATTRIBUTES = array( - 'lock' => array( 'type' => 'object' ), + 'lock' => array( 'type' => 'object' ), + 'metadata' => array( 'type' => 'object' ), ); /** diff --git a/tests/phpunit/tests/admin/includesPost.php b/tests/phpunit/tests/admin/includesPost.php index 5b07f23568b9d..dcf0a4952f4b5 100644 --- a/tests/phpunit/tests/admin/includesPost.php +++ b/tests/phpunit/tests/admin/includesPost.php @@ -935,7 +935,8 @@ public function test_get_block_editor_server_block_settings() { 'description' => '', 'icon' => 'text', 'attributes' => array( - 'lock' => array( 'type' => 'object' ), + 'lock' => array( 'type' => 'object' ), + 'metadata' => array( 'type' => 'object' ), ), 'usesContext' => array(), 'blockHooks' => array( 'core/post-content' => 'before' ), diff --git a/tests/phpunit/tests/blocks/register.php b/tests/phpunit/tests/blocks/register.php index 525d7498ae300..012171e38acfe 100644 --- a/tests/phpunit/tests/blocks/register.php +++ b/tests/phpunit/tests/blocks/register.php @@ -726,6 +726,7 @@ public function data_register_block_registers_with_args_override_returns_false_w * @ticket 50263 * @ticket 50328 * @ticket 57585 + * @ticket 59797 */ public function test_block_registers_with_metadata_fixture() { $result = register_block_type_from_metadata( @@ -744,10 +745,11 @@ public function test_block_registers_with_metadata_fixture() { $this->assertSameSets( array( 'alert', 'message' ), $result->keywords ); $this->assertSame( array( - 'message' => array( + 'message' => array( 'type' => 'string', ), - 'lock' => array( 'type' => 'object' ), + 'lock' => array( 'type' => 'object' ), + 'metadata' => array( 'type' => 'object' ), ), $result->attributes ); diff --git a/tests/phpunit/tests/blocks/wpBlock.php b/tests/phpunit/tests/blocks/wpBlock.php index dcafe53378ef3..f3edcb8302d81 100644 --- a/tests/phpunit/tests/blocks/wpBlock.php +++ b/tests/phpunit/tests/blocks/wpBlock.php @@ -59,6 +59,7 @@ public function test_constructor_assigns_properties_from_parsed_block() { /** * @ticket 49927 + * @ticket 59797 */ public function test_constructor_assigns_block_type_from_registry() { $block_type_settings = array( @@ -83,6 +84,7 @@ public function test_constructor_assigns_block_type_from_registry() { 'default' => 10, ), 'lock' => array( 'type' => 'object' ), + 'metadata' => array( 'type' => 'object' ), ), $block->block_type->attributes ); diff --git a/tests/phpunit/tests/blocks/wpBlockType.php b/tests/phpunit/tests/blocks/wpBlockType.php index 330d082bc2f1c..d2c7a13e6b345 100644 --- a/tests/phpunit/tests/blocks/wpBlockType.php +++ b/tests/phpunit/tests/blocks/wpBlockType.php @@ -80,6 +80,7 @@ public function test_set_props() { /* * @ticket 55567 + * @ticket 59797 * @covers WP_Block_Type::set_props */ public function test_core_attributes() { @@ -87,7 +88,8 @@ public function test_core_attributes() { $this->assertSameSetsWithIndex( array( - 'lock' => array( 'type' => 'object' ), + 'lock' => array( 'type' => 'object' ), + 'metadata' => array( 'type' => 'object' ), ), $block_type->attributes ); @@ -95,6 +97,7 @@ public function test_core_attributes() { /* * @ticket 55567 + * @ticket 59797 * @covers WP_Block_Type::set_props */ public function test_core_attributes_matches_custom() { @@ -102,9 +105,12 @@ public function test_core_attributes_matches_custom() { 'core/fake', array( 'attributes' => array( - 'lock' => array( + 'lock' => array( 'type' => 'string', ), + 'metadata' => array( + 'type' => 'number', + ), ), ) ); @@ -112,7 +118,8 @@ public function test_core_attributes_matches_custom() { // Backward compatibility: Don't override attributes with the same name. $this->assertSameSetsWithIndex( array( - 'lock' => array( 'type' => 'string' ), + 'lock' => array( 'type' => 'string' ), + 'metadata' => array( 'type' => 'number' ), ), $block_type->attributes ); diff --git a/tests/phpunit/tests/rest-api/rest-block-type-controller.php b/tests/phpunit/tests/rest-api/rest-block-type-controller.php index 2745b61195863..8b49d2c034a20 100644 --- a/tests/phpunit/tests/rest-api/rest-block-type-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-type-controller.php @@ -198,6 +198,7 @@ public function test_get_block_invalid_name() { * @ticket 47620 * @ticket 57585 * @ticket 59346 + * @ticket 59797 */ public function test_get_item_invalid() { $block_type = 'fake/invalid'; @@ -242,7 +243,8 @@ public function test_get_item_invalid() { $this->assertNull( $data['textdomain'] ); $this->assertSameSetsWithIndex( array( - 'lock' => array( 'type' => 'object' ), + 'lock' => array( 'type' => 'object' ), + 'metadata' => array( 'type' => 'object' ), ), $data['attributes'] ); @@ -272,6 +274,7 @@ public function test_get_item_invalid() { * @ticket 47620 * @ticket 57585 * @ticket 59346 + * @ticket 59797 */ public function test_get_item_defaults() { $block_type = 'fake/false'; @@ -316,7 +319,8 @@ public function test_get_item_defaults() { $this->assertNull( $data['textdomain'] ); $this->assertSameSetsWithIndex( array( - 'lock' => array( 'type' => 'object' ), + 'lock' => array( 'type' => 'object' ), + 'metadata' => array( 'type' => 'object' ), ), $data['attributes'] );