Skip to content

Commit

Permalink
Improve block styles check
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 24, 2022
1 parent 60ec9b7 commit 40bb25c
Showing 1 changed file with 16 additions and 4 deletions.
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

0 comments on commit 40bb25c

Please sign in to comment.