From: Bartosz DziewoƄski Date: Mon, 18 Aug 2014 12:56:18 +0000 (+0200) Subject: Add a test for mixed /*@noflip*/ and /*@embed*/ CSS annotations X-Git-Tag: 1.31.0-rc.0~14221^2~1 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=90c13419f0899218ac5437e6102658dd6e73b63f;p=lhc%2Fweb%2Fwiklou.git Add a test for mixed /*@noflip*/ and /*@embed*/ CSS annotations Given that we have entirely separate code for handling one and the other, and given the nature of code comments stuffed inside other structures, this isn't really obvious that they work. And indeed, "/*@noflip*/ /*@embed*/" doesn't work (filed bug 69698). Amazingly, all other combinations do. Change-Id: Ie30bab251eb4abee122c783d057de4102e53d1fc --- diff --git a/tests/phpunit/ResourceLoaderTestCase.php b/tests/phpunit/ResourceLoaderTestCase.php index f316f56317..96eedb4940 100644 --- a/tests/phpunit/ResourceLoaderTestCase.php +++ b/tests/phpunit/ResourceLoaderTestCase.php @@ -1,10 +1,10 @@ 'en', + 'lang' => $lang, 'modules' => 'startup', 'only' => 'scripts', 'skin' => 'vector', diff --git a/tests/phpunit/data/css/expected.css b/tests/phpunit/data/css/expected.css new file mode 100644 index 0000000000..74eb21eff3 --- /dev/null +++ b/tests/phpunit/data/css/expected.css @@ -0,0 +1,12 @@ +/* All of the combinations should result in the same output in LTR and RTL mode. */ + +.selector { /*@embed*/ background-image: url(simple-ltr.gif); } + +.selector { /*@embed*/ background-image: url(simple-ltr.gif); } + +/* Doesn't work! */ +/*.selector { /*@noflip* / /*@embed* / background-image: url(simple-ltr.gif); }*/ + +.selector { /*@embed*/ background-image: url(simple-ltr.gif); } + +.selector { /*@embed*/ background-image: url(simple-ltr.gif); } diff --git a/tests/phpunit/data/css/simple-ltr.gif b/tests/phpunit/data/css/simple-ltr.gif new file mode 100644 index 0000000000..13c43e906c Binary files /dev/null and b/tests/phpunit/data/css/simple-ltr.gif differ diff --git a/tests/phpunit/data/css/simple-rtl.gif b/tests/phpunit/data/css/simple-rtl.gif new file mode 100644 index 0000000000..f9e7531658 Binary files /dev/null and b/tests/phpunit/data/css/simple-rtl.gif differ diff --git a/tests/phpunit/data/css/test.css b/tests/phpunit/data/css/test.css new file mode 100644 index 0000000000..bf589ad4d3 --- /dev/null +++ b/tests/phpunit/data/css/test.css @@ -0,0 +1,12 @@ +/* All of the combinations should result in the same output in LTR and RTL mode. */ + +/*@noflip*/ .selector { /*@embed*/ background-image: url(simple-ltr.gif); } + +/*@noflip*/ .selector { background-image: /*@embed*/ url(simple-ltr.gif); } + +/* Doesn't work! */ +/*.selector { /*@noflip* / /*@embed* / background-image: url(simple-ltr.gif); }*/ + +.selector { /*@embed*/ /*@noflip*/ background-image: url(simple-ltr.gif); } + +.selector { /*@noflip*/ background-image: /*@embed*/ url(simple-ltr.gif); } diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index bd6b3f2329..12ec9ddde2 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -90,6 +90,36 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { $this->assertStringEqualsFile( $basePath . '/styles.css', $styles['all'] ); } + /** + * What happens when you mix @embed and @noflip? + * This really is an integration test, but oh well. + */ + public function testMixedCssAnnotations( ) { + $basePath = __DIR__ . '/../../data/css'; + $testModule = new ResourceLoaderFileModule( array( + 'localBasePath' => $basePath, + 'styles' => array( 'test.css' ), + ) ); + $expectedModule = new ResourceLoaderFileModule( array( + 'localBasePath' => $basePath, + 'styles' => array( 'expected.css' ), + ) ); + + $contextLtr = self::getResourceLoaderContext( 'en' ); + $contextRtl = self::getResourceLoaderContext( 'he' ); + + $this->assertEquals( + $expectedModule->getStyles( $contextLtr ), + str_replace( '/*@noflip*/ ', '', $testModule->getStyles( $contextLtr ) ), + "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode" + ); + $this->assertEquals( + $expectedModule->getStyles( $contextLtr ), + str_replace( '/*@noflip*/ ', '', $testModule->getStyles( $contextRtl ) ), + "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode" + ); + } + /** * @dataProvider providePackedModules * @covers ResourceLoader::makePackedModulesString