Skip to content
Closed
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
Added empty test
  • Loading branch information
ramonjd committed Feb 10, 2024
commit 63b29de4626fc368888112834a3fa6e50e226335
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function add_rules( $rules ) {
if ( ! $rule instanceof WP_Style_Engine_CSS_Rule ) {
_doing_it_wrong(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can't seem to unit test this using $this->expectNotice();

__METHOD__,
__( 'Rules passed to WP_Style_Engine_CSS_Rules_Containermust be an instance of WP_Style_Engine_CSS_Rule', 'default' ),
__( 'Rules passed to WP_Style_Engine_CSS_Rules_Container must be an instance of WP_Style_Engine_CSS_Rule', 'default' ),
'6.6.0'
);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,19 @@ public function test_should_instantiate_with_selector_and_rules() {
}

/**
* Tests that only WP_Style_Engine_CSS_Rule can be added to a container.
* Tests that empty values cannot be added.
*
* @covers ::add_rules
* @covers ::get_rules
*/
public function test_should_only_add_rule_objects() {
public function test_cannot_add_empty_values() {
$css_container = new WP_Style_Engine_CSS_Rules_Container_Gutenberg( '@media not all and (hover: hover)' );

$css_container->add_rules( '' );
$this->assertSame( array(), $css_container->get_rules(), 'Return value of get_rules() does not match expected rules when empty string added.' );
$this->assertEmpty( $css_container->get_rules(), 'Return value of get_rules() does not match expected rules when empty string added.' );

$css_container->add_rules( array() );
$this->assertSame( array(), $css_container->get_rules(), 'Return value of get_rules() does not match expected rules when array() added.' );

$css_container->add_rules( new WP_Style_Engine_CSS_Rules_Container_Gutenberg( '@media not all and (hover: hover)' ) );
$this->assertSame( array(), $css_container->get_rules(), 'Return value of get_rules() does not match expected rules when unknown class added.' );
$this->assertEmpty( $css_container->get_rules(), 'Return value of get_rules() does not match expected rules when array() added.' );
}

/**
Expand Down