mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Ports theme.json changes for beta 3.
- Add _wp_to_kebab_case function - Add CSS Custom Properties within preset classes. Props nosolosw. See #53397. git-svn-id: https://develop.svn.wordpress.org/trunk@51198 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
40
tests/phpunit/tests/functions/wpToKebabCase.php
Normal file
40
tests/phpunit/tests/functions/wpToKebabCase.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests for the _wp_to_kebab_case() function
|
||||
*
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @group functions.php
|
||||
* @covers ::_wp_to_kebab_case
|
||||
*/
|
||||
class Tests_Functions_wpToKebabCase extends WP_UnitTestCase {
|
||||
|
||||
public function test_wp_to_kebab_case() {
|
||||
$this->assertEquals( 'white', _wp_to_kebab_case( 'white' ) );
|
||||
$this->assertEquals( 'white-black', _wp_to_kebab_case( 'white+black' ) );
|
||||
$this->assertEquals( 'white-black', _wp_to_kebab_case( 'white:black' ) );
|
||||
$this->assertEquals( 'white-black', _wp_to_kebab_case( 'white*black' ) );
|
||||
$this->assertEquals( 'white-black', _wp_to_kebab_case( 'white.black' ) );
|
||||
$this->assertEquals( 'white-black', _wp_to_kebab_case( 'white black' ) );
|
||||
$this->assertEquals( 'white-black', _wp_to_kebab_case( 'white black' ) );
|
||||
$this->assertEquals( 'white-to-black', _wp_to_kebab_case( 'white-to-black' ) );
|
||||
$this->assertEquals( 'white-2-white', _wp_to_kebab_case( 'white2white' ) );
|
||||
$this->assertEquals( 'white-2nd', _wp_to_kebab_case( 'white2nd' ) );
|
||||
$this->assertEquals( 'white-2-ndcolor', _wp_to_kebab_case( 'white2ndcolor' ) );
|
||||
$this->assertEquals( 'white-2nd-color', _wp_to_kebab_case( 'white2ndColor' ) );
|
||||
$this->assertEquals( 'white-2nd-color', _wp_to_kebab_case( 'white2nd_color' ) );
|
||||
$this->assertEquals( 'white-23-color', _wp_to_kebab_case( 'white23color' ) );
|
||||
$this->assertEquals( 'white-23', _wp_to_kebab_case( 'white23' ) );
|
||||
$this->assertEquals( '23-color', _wp_to_kebab_case( '23color' ) );
|
||||
$this->assertEquals( 'white-4th', _wp_to_kebab_case( 'white4th' ) );
|
||||
$this->assertEquals( 'font-2-xl', _wp_to_kebab_case( 'font2xl' ) );
|
||||
$this->assertEquals( 'white-to-white', _wp_to_kebab_case( 'whiteToWhite' ) );
|
||||
$this->assertEquals( 'white-t-owhite', _wp_to_kebab_case( 'whiteTOwhite' ) );
|
||||
$this->assertEquals( 'whit-eto-white', _wp_to_kebab_case( 'WHITEtoWHITE' ) );
|
||||
$this->assertEquals( '42', _wp_to_kebab_case( 42 ) );
|
||||
$this->assertEquals( 'ive-done', _wp_to_kebab_case( "i've done" ) );
|
||||
$this->assertEquals( 'ffffff', _wp_to_kebab_case( '#ffffff' ) );
|
||||
$this->assertEquals( 'ffffff', _wp_to_kebab_case( '$ffffff' ) );
|
||||
}
|
||||
}
|
||||
@@ -294,11 +294,11 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'body{--wp--preset--color--grey: grey;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}a{background-color: #333;color: #111;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}',
|
||||
'body{--wp--preset--color--grey: grey;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}a{background-color: #333;color: #111;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}',
|
||||
$theme_json->get_stylesheet()
|
||||
);
|
||||
$this->assertSame(
|
||||
'body{color: var(--wp--preset--color--grey);}a{background-color: #333;color: #111;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}',
|
||||
'body{color: var(--wp--preset--color--grey);}a{background-color: #333;color: #111;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}',
|
||||
$theme_json->get_stylesheet( 'block_styles' )
|
||||
);
|
||||
$this->assertSame(
|
||||
@@ -329,7 +329,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'h1.has-white-color,h2.has-white-color,h3.has-white-color,h4.has-white-color,h5.has-white-color,h6.has-white-color{color: #fff !important;}h1.has-white-background-color,h2.has-white-background-color,h3.has-white-background-color,h4.has-white-background-color,h5.has-white-background-color,h6.has-white-background-color{background-color: #fff !important;}',
|
||||
'h1.has-white-color,h2.has-white-color,h3.has-white-color,h4.has-white-color,h5.has-white-color,h6.has-white-color{color: var(--wp--preset--color--white) !important;}h1.has-white-background-color,h2.has-white-background-color,h3.has-white-background-color,h4.has-white-background-color,h5.has-white-background-color,h6.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}',
|
||||
$theme_json->get_stylesheet( 'block_styles' )
|
||||
);
|
||||
}
|
||||
@@ -365,11 +365,11 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'.wp-block-group{--wp--preset--color--grey: grey;}.wp-block-group{color: red;}.wp-block-group.has-grey-color{color: grey !important;}.wp-block-group.has-grey-background-color{background-color: grey !important;}',
|
||||
'.wp-block-group{--wp--preset--color--grey: grey;}.wp-block-group{color: red;}.wp-block-group.has-grey-color{color: var(--wp--preset--color--grey) !important;}.wp-block-group.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}',
|
||||
$theme_json->get_stylesheet()
|
||||
);
|
||||
$this->assertSame(
|
||||
'.wp-block-group{color: red;}.wp-block-group.has-grey-color{color: grey !important;}.wp-block-group.has-grey-background-color{background-color: grey !important;}',
|
||||
'.wp-block-group{color: red;}.wp-block-group.has-grey-color{color: var(--wp--preset--color--grey) !important;}.wp-block-group.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}',
|
||||
$theme_json->get_stylesheet( 'block_styles' )
|
||||
);
|
||||
}
|
||||
@@ -407,7 +407,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'body{--wp--preset--color--grey: grey;}p{background-color: blue;color: red;font-size: 12px;line-height: 1.3;}.has-grey-color{color: grey !important;}.has-grey-background-color{background-color: grey !important;}',
|
||||
'body{--wp--preset--color--grey: grey;}p{background-color: blue;color: red;font-size: 12px;line-height: 1.3;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}',
|
||||
$theme_json->get_stylesheet()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user