Merge "maintenance: Document secondary purpose of --server"
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / CSSMinTest.php
index 89cf68f..f2d5ef3 100644 (file)
@@ -149,6 +149,12 @@ class CSSMinTest extends MediaWikiTestCase {
                        [ "foo { content: '\"'; }", "foo{content:'\"'}" ],
                        // - Whitespace in string values
                        [ 'foo { content: " "; }', 'foo{content:" "}' ],
+
+                       // Whitespaces after opening and before closing parentheses and brackets
+                       [ 'a:not( [ href ] ) { prop: url( foobar.png ); }', 'a:not([href]){prop:url(foobar.png)}' ],
+
+                       // Ensure that the invalid "url (" will not become the valid "url(" by minification
+                       [ 'foo { prop: url ( foobar.png ); }', 'foo{prop:url (foobar.png)}' ],
                ];
        }
 
@@ -247,6 +253,36 @@ class CSSMinTest extends MediaWikiTestCase {
                ];
        }
 
+       /**
+        * Cases with empty url() for CSSMin::remap.
+        *
+        * Regression test for T191237.
+   *
+        * @dataProvider provideRemapEmptyUrl
+        * @covers CSSMin
+        */
+       public function testRemapEmptyUrl( $params, $expected ) {
+               $remapped = call_user_func_array( 'CSSMin::remap', $params );
+               $this->assertEquals( $expected, $remapped, 'Ignore empty url' );
+       }
+
+       public static function provideRemapEmptyUrl() {
+               return [
+                       'Empty' => [
+                               [ "background-image: url();", false, '/example', false ],
+                               "background-image: url();",
+                       ],
+                       'Single quote' => [
+                               [ "background-image: url('');", false, '/example', false ],
+                               "background-image: url('');",
+                       ],
+                       'Double quote' => [
+                               [ 'background-image: url("");', false, '/example', false ],
+                               'background-image: url("");',
+                       ],
+               ];
+       }
+
        /**
         * This tests the basic functionality of CSSMin::remap.
         *