From 3d05810370aeea66587b26b6775e45b421ee4a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 14 Jun 2024 17:16:42 +0200 Subject: [PATCH] Revert "Revert test data for `WithSlug` variation (#62579)" This reverts commit 2917269cf70405990ab4b1cd3f961a714dc5f5f6. --- .../block-style-variations-test.php | 23 +++++++++++++++++++ phpunit/class-wp-theme-json-resolver-test.php | 12 ++++++++++ .../block-style-variation-with-slug.json | 12 ++++++++++ 3 files changed, 47 insertions(+) create mode 100644 phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json diff --git a/phpunit/block-supports/block-style-variations-test.php b/phpunit/block-supports/block-style-variations-test.php index 870a76a4fb4a49..62fa923dbdd7e9 100644 --- a/phpunit/block-supports/block-style-variations-test.php +++ b/phpunit/block-supports/block-style-variations-test.php @@ -94,6 +94,22 @@ public function test_add_registered_block_styles_to_theme_data() { ), ); + /* + * This style is to be deliberately overwritten by the theme.json partial + * See `phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json`. + */ + register_block_style( + 'core/group', + array( + 'name' => 'WithSlug', + 'style_data' => array( + 'color' => array( + 'background' => 'whitesmoke', + 'text' => 'black', + ), + ), + ) + ); register_block_style( 'core/group', array( @@ -106,6 +122,12 @@ public function test_add_registered_block_styles_to_theme_data() { $group_styles = $theme_json['styles']['blocks']['core/group'] ?? array(); $expected = array( 'variations' => array( + 'WithSlug' => array( + 'color' => array( + 'background' => 'aliceblue', + 'text' => 'midnightblue', + ), + ), 'my-variation' => $variation_styles_data, /* @@ -129,6 +151,7 @@ public function test_add_registered_block_styles_to_theme_data() { ); unregister_block_style( 'core/group', 'my-variation' ); + unregister_block_style( 'core/group', 'WithSlug' ); $this->assertSameSetsWithIndex( $group_styles, $expected ); } diff --git a/phpunit/class-wp-theme-json-resolver-test.php b/phpunit/class-wp-theme-json-resolver-test.php index 50e1d9d846899e..6333c3d1dd7760 100644 --- a/phpunit/class-wp-theme-json-resolver-test.php +++ b/phpunit/class-wp-theme-json-resolver-test.php @@ -1118,6 +1118,18 @@ public function data_get_style_variations() { ), ), ), + array( + 'blockTypes' => array( 'core/group', 'core/columns' ), + 'version' => 3, + 'slug' => 'WithSlug', + 'title' => 'With Slug', + 'styles' => array( + 'color' => array( + 'background' => 'aliceblue', + 'text' => 'midnightblue', + ), + ), + ), ), ), ); diff --git a/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json b/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json new file mode 100644 index 00000000000000..d938a8a0db833c --- /dev/null +++ b/phpunit/data/themedir1/block-theme/styles/block-style-variation-with-slug.json @@ -0,0 +1,12 @@ +{ + "version": 3, + "blockTypes": [ "core/group", "core/columns" ], + "slug": "WithSlug", + "title": "With Slug", + "styles": { + "color": { + "background": "aliceblue", + "text": "midnightblue" + } + } +}