X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flibs%2FCSSJanusTest.php;h=c8b20d2a8b05dc320e68cddc79a35ee7b235dbda;hb=d2aa30c032f92f601262d8cdb611c481e87d6ad9;hp=a1b87f63ae9731ccccacc5d29c4bedb9f6943310;hpb=a6c3d5e6252d33984cf023a587411b00efba5d97;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/libs/CSSJanusTest.php b/tests/phpunit/includes/libs/CSSJanusTest.php index a1b87f63ae..c8b20d2a8b 100644 --- a/tests/phpunit/includes/libs/CSSJanusTest.php +++ b/tests/phpunit/includes/libs/CSSJanusTest.php @@ -4,12 +4,14 @@ * CSSJanus libary: * http://code.google.com/p/cssjanus/source/browse/trunk/cssjanus_test.py * Ported to PHP for ResourceLoader and has been extended since. + * + * @covers CSSJanus */ class CSSJanusTest extends MediaWikiTestCase { /** * @dataProvider provideTransformCases */ - function testTransform( $cssA, $cssB = null ) { + public function testTransform( $cssA, $cssB = null ) { if ( $cssB ) { $transformedA = CSSJanus::transform( $cssA ); @@ -28,9 +30,11 @@ class CSSJanusTest extends MediaWikiTestCase { /** * @dataProvider provideTransformAdvancedCases */ - function testTransformAdvanced( $code, $expectedOutput, $options = array() ) { - $swapLtrRtlInURL = isset( $options['swapLtrRtlInURL'] ) ? $options['swapLtrRtlInURL'] : false; - $swapLeftRightInURL = isset( $options['swapLeftRightInURL'] ) ? $options['swapLeftRightInURL'] : false; + public function testTransformAdvanced( $code, $expectedOutput, $options = array() ) { + $swapLtrRtlInURL = isset( $options['swapLtrRtlInURL'] ) ? + $options['swapLtrRtlInURL'] : false; + $swapLeftRightInURL = isset( $options['swapLeftRightInURL'] ) ? + $options['swapLeftRightInURL'] : false; $flipped = CSSJanus::transform( $code, $swapLtrRtlInURL, $swapLeftRightInURL ); @@ -44,7 +48,7 @@ class CSSJanusTest extends MediaWikiTestCase { * @dataProvider provideTransformBrokenCases * @group Broken */ - function testTransformBroken( $code, $expectedOutput ) { + public function testTransformBroken( $code, $expectedOutput ) { $flipped = CSSJanus::transform( $code ); $this->assertEquals( $expectedOutput, $flipped, 'Test flipping' ); @@ -137,10 +141,15 @@ class CSSJanusTest extends MediaWikiTestCase { '.foo { padding: 1px inherit 3px auto; }', '.foo { padding: 1px auto 3px inherit; }' ), + // border-radius assigns different meanings to the values array( '.foo { border-radius: .25em 15px 0pt 0ex; }', - '.foo { border-radius: .25em 0ex 0pt 15px; }' + '.foo { border-radius: 15px .25em 0ex 0pt; }' ), + array( + '.foo { border-radius: 0px 0px 5px 5px; }', + ), + // Ensure the rule doesn't break other stuff array( '.foo { x-unknown: a b c d; }' ), @@ -150,6 +159,21 @@ class CSSJanusTest extends MediaWikiTestCase { array( '#settings td p strong' ), + array( + // Color names + '.foo { border-color: red green blue white }', + '.foo { border-color: red white blue green }', + ), + array( + // Color name, hexdecimal, RGB & RGBA + '.foo { border-color: red #f00 rgb(255, 0, 0) rgba(255, 0, 0, 0.5) }', + '.foo { border-color: red rgba(255, 0, 0, 0.5) rgb(255, 0, 0) #f00 }', + ), + array( + // Color name, hexdecimal, HSL & HSLA + '.foo { border-color: red #f00 hsl(0, 100%, 50%) hsla(0, 100%, 50%, 0.5) }', + '.foo { border-color: red hsla(0, 100%, 50%, 0.5) hsl(0, 100%, 50%) #f00 }', + ), array( // Do not mangle 5 or more values '.foo { -x-unknown: 1 2 3 4 5; }' @@ -176,6 +200,28 @@ class CSSJanusTest extends MediaWikiTestCase { '.foo { padding: 1px; }' ), + // text-shadow and box-shadow + array( + '.foo { box-shadow: -6px 3px 8px 5px rgba(0, 0, 0, 0.25); }', + '.foo { box-shadow: 6px 3px 8px 5px rgba(0, 0, 0, 0.25); }', + ), + array( + '.foo { box-shadow: inset -6px 3px 8px 5px rgba(0, 0, 0, 0.25); }', + '.foo { box-shadow: inset 6px 3px 8px 5px rgba(0, 0, 0, 0.25); }', + ), + array( + '.foo { text-shadow: orange 2px 0; }', + '.foo { text-shadow: orange -2px 0; }', + ), + array( + '.foo { text-shadow: 2px 0 orange; }', + '.foo { text-shadow: -2px 0 orange; }', + ), + array( + // Don't mangle zeroes + '.foo { text-shadow: orange 0 2px; }' + ), + // Direction // Note: This differs from the Python implementation, // see also CSSJanus::fixDirection for more info. @@ -373,6 +419,11 @@ class CSSJanusTest extends MediaWikiTestCase { '/* @noflip */ div { float: left; } .foo { float: left; }', '/* @noflip */ div { float: left; } .foo { float: right; }' ), + array( + // support parentheses in selector + '/* @noflip */ .test:not(:first) { margin-right: -0.25em; margin-left: 0.25em; }', + '/* @noflip */ .test:not(:first) { margin-right: -0.25em; margin-left: 0.25em; }' + ), array( // after multiple rules '.foo { float: left; } /* @noflip */ div { float: left; }', @@ -388,6 +439,26 @@ class CSSJanusTest extends MediaWikiTestCase { 'div { float: left; /* @noflip */ text-align: left; }', 'div { float: right; /* @noflip */ text-align: left; }' ), + array( + // before a *= attribute selector with multiple properties + '/* @noflip */ div.foo[bar*=baz] { float:left; clear: left; }' + ), + array( + // before a ^= attribute selector with multiple properties + '/* @noflip */ div.foo[bar^=baz] { float:left; clear: left; }' + ), + array( + // before a ~= attribute selector with multiple properties + '/* @noflip */ div.foo[bar~=baz] { float:left; clear: left; }' + ), + array( + // before a = attribute selector with multiple properties + '/* @noflip */ div.foo[bar=baz] { float:left; clear: left; }' + ), + array( + // before a quoted attribute selector with multiple properties + '/* @noflip */ div.foo[bar=\'baz{quux\'] { float:left; clear: left; }' + ), // Guard against css3 stuff array(