CSSMin::serializeStringValue: Update implementation to new specification
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / CSSMinTest.php
index f2d5ef3..59a1c7c 100644 (file)
@@ -22,6 +22,43 @@ class CSSMinTest extends MediaWikiTestCase {
                ] );
        }
 
+       /**
+        * @dataProvider serializeStringValueProvider
+        * @covers CSSMin::serializeStringValue
+        */
+       public function testSerializeStringValue( $input, $expected ) {
+               $output = CSSMin::serializeStringValue( $input );
+               $this->assertEquals(
+                       $expected,
+                       $output,
+                       'Serialized output must be in the expected form.'
+               );
+       }
+
+       public function serializeStringValueProvider() {
+               return [
+                       [ 'Hello World!', '"Hello World!"' ],
+                       [ "Null\0Null", "\"Null\\fffd Null\"" ],
+                       [ '"', '"\\""' ],
+                       [ "'", '"\'"' ],
+                       [ "\\", '"\\\\"' ],
+                       [ "Tab\tTab", '"Tab\\9 Tab"' ],
+                       [ "Space  tab \t space", '"Space  tab \\9  space"' ],
+                       [ "Line\nfeed", '"Line\\a feed"' ],
+                       [ "Return\rreturn", '"Return\\d return"' ],
+                       [ "Next\xc2\x85line", "\"Next\xc2\x85line\"" ],
+                       [ "Del\x7fDel", '"Del\\7f Del"' ],
+                       [ "nb\xc2\xa0sp", "\"nb\xc2\xa0sp\"" ],
+                       [ "AMP&AMP", "\"AMP&AMP\"" ],
+                       [ '!"#$%&\'()*+,-./0123456789:;<=>?', '"!\\"#$%&\'()*+,-./0123456789:;<=>?"' ],
+                       [ '@[\\]^_`{|}~', '"@[\\\\]^_`{|}~"' ],
+                       [ 'ä', '"ä"' ],
+                       [ 'Ä', '"Ä"' ],
+                       [ '€', '"€"' ],
+                       [ '𝒞', '"𝒞"' ], // U+1D49E 'MATHEMATICAL SCRIPT CAPITAL C'
+               ];
+       }
+
        /**
         * @dataProvider mimeTypeProvider
         * @covers CSSMin::getMimeType