-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating @return comment to reflect usage
Adding base test file Whatever, linter.
- Loading branch information
Showing
3 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
phpunit/style-engine/class-wp-style-engine-gutenberg-test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Tests the Style Engine class and associated functionality. | ||
* | ||
* @package Gutenberg | ||
* @subpackage block-library | ||
*/ | ||
|
||
/** | ||
* Tests for registering, storing and generating styles. | ||
*/ | ||
class WP_Style_Engine_Gutenberg_Test extends WP_UnitTestCase { | ||
function test_returns_inline_styles_from_string() { | ||
$style_engine = WP_Style_Engine_Gutenberg::get_instance(); | ||
$block_styles = array( | ||
'spacing' => array( | ||
'padding' => '111px', | ||
), | ||
); | ||
$padding_styles = $style_engine->get_inline_styles_from_attributes( | ||
$block_styles, | ||
array( 'spacing', 'padding' ) | ||
); | ||
$expected = 'padding:111px;'; | ||
$this->assertSame( $expected, $padding_styles ); | ||
} | ||
|
||
function test_returns_inline_styles_from_box_rules() { | ||
$style_engine = WP_Style_Engine_Gutenberg::get_instance(); | ||
$block_styles = array( | ||
'spacing' => array( | ||
'padding' => array( | ||
'top' => '42px', | ||
'left' => '2%', | ||
'bottom' => '44px', | ||
'right' => '5rem', | ||
), | ||
), | ||
); | ||
$padding_styles = $style_engine->get_inline_styles_from_attributes( | ||
$block_styles, | ||
array( 'spacing', 'padding' ) | ||
); | ||
$expected = 'padding-top:42px;padding-left:2%;padding-bottom:44px;padding-right:5rem;'; | ||
$this->assertSame( $expected, $padding_styles ); | ||
} | ||
|
||
function test_returns_empty_string_when_invalid_path_passed() { | ||
$style_engine = WP_Style_Engine_Gutenberg::get_instance(); | ||
$block_styles = array( | ||
'spacing' => array( | ||
'padding' => '111px', | ||
), | ||
); | ||
$padding_styles = $style_engine->get_inline_styles_from_attributes( | ||
$block_styles, | ||
null | ||
); | ||
$expected = ''; | ||
$this->assertSame( $expected, $padding_styles ); | ||
} | ||
} |