Skip to content

Commit

Permalink
Post trunk merge cleanup and update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Jul 15, 2022
1 parent c2dde6b commit 0f7c753
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/style-engine/class-wp-style-engine-css-rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct( $selector = '', $declarations = array() ) {
*
* @param string $selector The CSS selector.
*
* @return WP_Style_Engine_CSS_Rule Returns the object to allow chaining of methods.
* @return WP_Style_Engine_CSS_Rule|void Returns the object to allow chaining of methods.
*/
public function set_selector( $selector ) {
if ( empty( $selector ) ) {
Expand Down Expand Up @@ -110,6 +110,6 @@ public function get_selector() {
* @return string
*/
public function get_css() {
return $this->get_selector() . ' {' . $this->declarations->get_declarations_string() . '}';
return $this->get_selector() . ' { ' . $this->declarations->get_declarations_string() . ' }';
}
}
5 changes: 3 additions & 2 deletions packages/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,10 @@ public function get_block_supports_styles( $block_styles, $options ) {
$styles_output['declarations'] = $css_declarations->get_declarations();
// Return an entire rule if there is a selector.
if ( $css_selector ) {
$styles_output['css'] = $css_selector . ' { ' . $css . ' }';
$css_rule = new WP_Style_Engine_CSS_Rule( $css_selector, $css_declarations );
$styles_output['css'] = $css_rule->get_css();
if ( $should_store_and_enqueue ) {
$stored_css_rule = static::$stores['block-supports']->get_rule( $css_selector );
$stored_css_rule = static::$stores['block-supports']->add_rule( $css_selector );
$stored_css_rule->set_declarations( $css_declarations );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function test_instantiate_with_selector_and_rules() {

$this->assertSame( $selector, $css_rule->get_selector() );

$expected = "$selector {{$css_declarations->get_declarations_string()}}";
$expected = "$selector { {$css_declarations->get_declarations_string()} }";
$this->assertSame( $expected, $css_rule->get_css() );
}

Expand All @@ -45,7 +45,7 @@ public function test_dedupe_properties_in_rules() {
$css_rule = new WP_Style_Engine_CSS_Rule( $selector, $first_declaration );
$css_rule->set_declarations( new WP_Style_Engine_CSS_Declarations( $overwrite_first_declaration ) );

$expected = '.taggart {font-size: 4px;}';
$expected = '.taggart { font-size: 4px; }';
$this->assertSame( $expected, $css_rule->get_css() );
}

Expand All @@ -60,7 +60,7 @@ public function test_set_declarations() {
$css_rule = new WP_Style_Engine_CSS_Rule( '.hill-street-blues', $some_css_declarations );
$css_rule->set_declarations( $some_more_css_declarations );

$expected = '.hill-street-blues {margin-top: 10px; font-size: 1rem;}';
$expected = '.hill-street-blues { margin-top: 10px; font-size: 1rem; }';
$this->assertSame( $expected, $css_rule->get_css() );
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public function test_get_css() {
);
$css_declarations = new WP_Style_Engine_CSS_Declarations( $input_declarations );
$css_rule = new WP_Style_Engine_CSS_Rule( $selector, $css_declarations );
$expected = "$selector {{$css_declarations->get_declarations_string()}}";
$expected = "$selector { {$css_declarations->get_declarations_string()} }";

$this->assertSame( $expected, $css_rule->get_css() );
}
Expand Down
2 changes: 2 additions & 0 deletions packages/style-engine/phpunit/class-wp-style-engine-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

require __DIR__ . '/../class-wp-style-engine-css-declarations.php';
require __DIR__ . '/../class-wp-style-engine-css-rule.php';
require __DIR__ . '/../class-wp-style-engine-css-rules-store.php';
require __DIR__ . '/../class-wp-style-engine.php';

/**
Expand Down

0 comments on commit 0f7c753

Please sign in to comment.