Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add unit test for resolver class.
  • Loading branch information
jffng authored and ockham committed Jan 16, 2023
commit 23932115883f2e60cb12411a82df4af512e1df7c
59 changes: 59 additions & 0 deletions phpunit/class-wp-theme-json-resolver-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,63 @@ public function data_get_merged_data_returns_origin() {
);
}

public function test_get_style_variations_returns_all_variations() {
// Switch to a child theme.
switch_theme( 'block-theme-child' );
wp_set_current_user( self::$administrator_id );

$actual_settings = WP_Theme_JSON_Resolver_Gutenberg::get_style_variations();
$expected_settings = array(
array(
'version' => 2,
'title' => 'variation-child',
'settings' => array(
'blocks' => array(
'core/post-title' => array(
'color' => array(
'palette' => array(
'theme' => array(
array(
'slug' => 'light',
'name' => 'Light',
'color' => '#f1f1f1',
),
),
),
),
),
),
),
),
array(
'version' => 2,
'title' => 'variation',
'settings' => array(
'blocks' => array(
'core/paragraph' => array(
'color' => array(
'palette' => array(
'theme' => array(
array(
'slug' => 'light',
'name' => 'Light',
'color' => '#f2f2f2',
),
),
),
),
),
),
),
),
);
self::recursive_ksort( $actual_settings );
self::recursive_ksort( $expected_settings );

$this->assertSame(
$expected_settings,
$actual_settings
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"settings": {
"blocks": {
"core/post-title": {
"color": {
"palette": [
{
"slug": "light",
"name": "Light",
"color": "#f1f1f1"
}
]
}
}
}
}
}
2 changes: 1 addition & 1 deletion phpunit/data/themedir1/block-theme-child/theme.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"version": 2,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the version number here, which seems like it was incorrect to begin with since it was already using the customTemplates and templateParts properties which were added in v2.

"settings": {
"color": {
"palette": [
Expand Down
18 changes: 18 additions & 0 deletions phpunit/data/themedir1/block-theme/styles/variation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"settings": {
"blocks": {
"core/paragraph": {
"color": {
"palette": [
{
"slug": "light",
"name": "Light",
"color": "#f2f2f2"
}
]
}
}
}
}
}
2 changes: 1 addition & 1 deletion phpunit/data/themedir1/block-theme/theme.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"version": 2,
"settings": {
"color": {
"palette": [
Expand Down