From 45d91ca6446304eee6d437e03015157b110a215f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 7 Dec 2021 17:10:35 +0100 Subject: [PATCH] Tests for block-level presets --- phpunit/class-wp-theme-json-test.php | 74 ++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 776e11656d9148..21ba51cc373757 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -1226,7 +1226,7 @@ public function test_merge_incoming_data_color_presets_with_same_slugs_as_defaul array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, 'settings' => array( - 'color' => array( + 'color' => array( 'defaultPalette' => true, // Emulate the defaults from core theme.json. 'palette' => array( array( @@ -1241,6 +1241,19 @@ public function test_merge_incoming_data_color_presets_with_same_slugs_as_defaul ), ), ), + 'blocks' => array( + 'core/paragraph' => array( + 'color' => array( + 'palette' => array( + array( + 'slug' => 'blue', + 'color' => 'blue', + 'name' => 'Blue', + ), + ), + ), + ), + ), ), ), 'default' @@ -1249,7 +1262,7 @@ public function test_merge_incoming_data_color_presets_with_same_slugs_as_defaul array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, 'settings' => array( - 'color' => array( + 'color' => array( 'defaultPalette' => false, 'palette' => array( array( @@ -1264,6 +1277,29 @@ public function test_merge_incoming_data_color_presets_with_same_slugs_as_defaul ), ), ), + 'blocks' => array( + 'core/paragraph' => array( + 'color' => array( + 'palette' => array( + array( + 'slug' => 'blue', + 'color' => 'blue', + 'name' => 'Bluish', + ), + array( + 'slug' => 'yellow', + 'color' => 'yellow', + 'name' => 'Yellow', + ), + array( + 'slug' => 'green', + 'color' => 'green', + 'name' => 'Block Green', + ), + ), + ), + ), + ), ), ) ); @@ -1271,7 +1307,7 @@ public function test_merge_incoming_data_color_presets_with_same_slugs_as_defaul $expected = array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, 'settings' => array( - 'color' => array( + 'color' => array( 'defaultPalette' => false, 'palette' => array( 'default' => array( @@ -1300,6 +1336,38 @@ public function test_merge_incoming_data_color_presets_with_same_slugs_as_defaul ), ), ), + 'blocks' => array( + 'core/paragraph' => array( + 'color' => array( + 'palette' => array( + 'default' => array( + array( + 'slug' => 'blue', + 'color' => 'blue', + 'name' => 'Blue', + ), + ), + 'theme' => array( + array( + 'slug' => 'blue', + 'color' => 'blue', + 'name' => 'Bluish', + ), + array( + 'slug' => 'yellow', + 'color' => 'yellow', + 'name' => 'Yellow', + ), + array( + 'slug' => 'green', + 'color' => 'green', + 'name' => 'Block Green', + ), + ), + ), + ), + ), + ), ), );