<?php
abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
- protected static function getResourceLoaderContext() {
+ protected static function getResourceLoaderContext( $lang = 'en' ) {
$resourceLoader = new ResourceLoader();
$request = new FauxRequest( array(
- 'lang' => 'en',
+ 'lang' => $lang,
'modules' => 'startup',
'only' => 'scripts',
'skin' => 'vector',
--- /dev/null
+/* 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); }
--- /dev/null
+/* 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); }
$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