Skip to content
Draft
Changes from all commits
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
30 changes: 30 additions & 0 deletions tests/phpunit/tests/theme/wpThemeJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -6119,4 +6119,34 @@ public function test_opt_in_to_block_style_variations() {

$this->assertSame( $expected, $button_variations );
}

/**
* Tests the custom CSS behaviour.
*
* @ticket n.e.x.t
*/
public function test_custom_css_behaviour() {
$theme_json = new WP_Theme_JSON(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'styles' => array(
'css' => 'body {color:purple;}',
'blocks' => array(
'core/paragraph' => array(
'css' => 'color:red;',
),
),
),
)
);

$custom_css = 'body {color:purple;}';
$block_custom_css = ':root :where(p){color:red;}';

if ( version_compare( get_bloginfo( 'version' ), '6.7', '>=' ) ) {
$this->assertSame( $custom_css, $theme_json->get_stylesheet( array( 'custom-css' ) ) );
} else {
$this->assertSame( $custom_css . $block_custom_css, $theme_json->get_custom_css() );
}
}
}