Skip to content
Merged
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
Improve block styles check
  • Loading branch information
oandregal committed Nov 24, 2022
commit 40bb25c46524597bcf16b648c011f6e218607a96
20 changes: 16 additions & 4 deletions phpunit/class-wp-theme-json-resolver-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ public function test_get_merged_data_returns_origin_default() {
$settings = $theme_json->get_settings();
$styles = $theme_json->get_styles_block_nodes();
$this->assertTrue( isset( $settings['color']['palette']['default'] ), 'core palette is present' );
$this->assertFalse( isset( $styles[4] ) , 'block styles are not present' );
$block_styles = array_filter( $styles, function( $element ) {
return isset( $element['name'] ) && $element['name'] === 'my/block-with-styles';
} );
$this->assertTrue( count( $block_styles ) === 0 , 'block styles are not present' );
$this->assertFalse( isset( $settings['color']['palette']['theme'] ), 'theme palette is not present' );
$this->assertFalse( isset( $settings['color']['palette']['custom'] ), 'user palette is not present' );

Expand All @@ -439,7 +442,10 @@ public function test_get_merged_data_returns_origin_blocks() {
$settings = $theme_json->get_settings();
$styles = $theme_json->get_styles_block_nodes();
$this->assertTrue( isset( $settings['color']['palette']['default'] ), 'core palette is present' );
$this->assertSame( $styles[4]['name'], 'my/block-with-styles' , 'block styles are present' );
$block_styles = array_filter( $styles, function( $element ) {
return isset( $element['name'] ) && $element['name'] === 'my/block-with-styles';
} );
$this->assertTrue( count( $block_styles ) === 1 , 'block styles are present' );
$this->assertFalse( isset( $settings['color']['palette']['theme'] ), 'theme palette is not present' );
$this->assertFalse( isset( $settings['color']['palette']['custom'] ), 'user palette is not present' );

Expand All @@ -463,7 +469,10 @@ public function test_get_merged_data_returns_origin_theme() {
$settings = $theme_json->get_settings();
$styles = $theme_json->get_styles_block_nodes();
$this->assertTrue( isset( $settings['color']['palette']['default'] ), 'core palette is present' );
$this->assertSame( $styles[4]['name'], 'my/block-with-styles' , 'block styles are present' );
$block_styles = array_filter( $styles, function( $element ) {
return isset( $element['name'] ) && $element['name'] === 'my/block-with-styles';
} );
$this->assertTrue( count( $block_styles ) === 1 , 'block styles are present' );
$this->assertTrue( isset( $settings['color']['palette']['theme'] ), 'theme palette is present' );
$this->assertFalse( isset( $settings['color']['palette']['custom'] ), 'user palette is not present' );

Expand All @@ -487,7 +496,10 @@ public function test_get_merged_data_returns_origin_custom() {
$settings = $theme_json->get_settings();
$styles = $theme_json->get_styles_block_nodes();
$this->assertTrue( isset( $settings['color']['palette']['default'] ), 'core palette is present' );
$this->assertSame( $styles[4]['name'], 'my/block-with-styles' , 'block styles are present' );
$block_styles = array_filter( $styles, function( $element ) {
return isset( $element['name'] ) && $element['name'] === 'my/block-with-styles';
} );
$this->assertTrue( count( $block_styles ) === 1 , 'block styles are present' );
$this->assertTrue( isset( $settings['color']['palette']['theme'] ), 'theme palette is present' );
$this->assertTrue( isset( $settings['color']['palette']['custom'] ), 'user palette is present' );

Expand Down