File tree Expand file tree Collapse file tree
tests/phpunit/tests/css-api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,29 @@ class Tests_CssApi_WpCssBuilder extends WP_UnitTestCase {
1515 */
1616 public function test_string_escaping ( string $ input , string $ expected ): void {
1717 $ this ->assertSame ( $ expected , WP_CSS_Builder::string ( $ input ) );
18+
19+ /**
20+ * Ensure that a single, equivalent CSS string is produced.
21+ *
22+ * CSS pre-processing normalization is applied to the input to ensure
23+ * a match can be found.
24+ *
25+ * @see https://www.w3.org/TR/css-syntax-3/#input-preprocessing
26+ */
27+ $ processor = WP_CSS_Token_Processor::create ( WP_CSS_Builder::string ( $ input ) );
28+ $ processor ->next_token ();
29+ $ this ->assertSame ( WP_CSS_Token_Processor::TOKEN_STRING , $ processor ->get_token_type () );
30+ $ expected_decoded_value = strtr (
31+ $ input ,
32+ array (
33+ "\r\n" => "\n" ,
34+ "\r" => "\n" ,
35+ "\f" => "\n" ,
36+ "\0" => '� ' ,
37+ )
38+ );
39+ $ this ->assertSame ( $ expected_decoded_value , $ processor ->get_token_value () );
40+ $ this ->assertFalse ( $ processor ->next_token () );
1841 }
1942
2043 /**
You can’t perform that action at this time.
0 commit comments