/** * 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), $testModule->getStyles($contextLtr), "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode"); $this->assertEquals($expectedModule->getStyles($contextLtr), $testModule->getStyles($contextRtl), "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode"); }
/** * What happens when you mix @embed and @noflip? * This really is an integration test, but oh well. * * @covers ResourceLoaderFileModule::getStyles * @covers ResourceLoaderFileModule::getStyleFiles */ 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 = $this->getResourceLoaderContext('en', 'ltr'); $contextRtl = $this->getResourceLoaderContext('he', 'rtl'); // Since we want to compare the effect of @noflip+@embed against the effect of just @embed, and // the @noflip annotations are always preserved, we need to strip them first. $this->assertEquals($expectedModule->getStyles($contextLtr), self::stripNoflip($testModule->getStyles($contextLtr)), "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode"); $this->assertEquals($expectedModule->getStyles($contextLtr), self::stripNoflip($testModule->getStyles($contextRtl)), "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode"); }
/** * @dataProvider provideResourceLoaderContext * @covers ResourceLoaderFileModule::compileLessFile */ public function testLessFileCompilation($context) { $basePath = __DIR__ . '/../data/less/module'; $module = new ResourceLoaderFileModule(array('localBasePath' => $basePath, 'styles' => array('styles.less'))); $styles = $module->getStyles($context); $this->assertStringEqualsFile($basePath . '/styles.css', $styles['all']); }
/** * @covers ResourceLoaderFileModule::compileLessFile */ public function testLessFileCompilation() { $context = $this->getResourceLoaderContext(); $basePath = __DIR__ . '/../../data/less/module'; $module = new ResourceLoaderFileModule(['localBasePath' => $basePath, 'styles' => ['styles.less']]); $module->setName('test.less'); $styles = $module->getStyles($context); $this->assertStringEqualsFile($basePath . '/styles.css', $styles['all']); }
/** * @param $context ResourceLoaderContext * @return array */ public function getStyles(ResourceLoaderContext $context) { $logo = $this->getConfig()->get('Logo'); $logoHD = $this->getConfig()->get('LogoHD'); $styles = parent::getStyles($context); $styles['all'][] = '.mw-wiki-logo { background-image: ' . CSSMin::buildUrlValue($logo) . '; }'; if ($logoHD) { if (isset($logoHD['1.5x'])) { $styles['(-webkit-min-device-pixel-ratio: 1.5), ' . '(min--moz-device-pixel-ratio: 1.5), ' . '(min-resolution: 1.5dppx), ' . '(min-resolution: 144dpi)'][] = '.mw-wiki-logo { background-image: ' . CSSMin::buildUrlValue($logoHD['1.5x']) . ';' . 'background-size: 135px auto; }'; } if (isset($logoHD['2x'])) { $styles['(-webkit-min-device-pixel-ratio: 2), ' . '(min--moz-device-pixel-ratio: 2),' . '(min-resolution: 2dppx), ' . '(min-resolution: 192dpi)'][] = '.mw-wiki-logo { background-image: ' . CSSMin::buildUrlValue($logoHD['2x']) . ';' . 'background-size: 135px auto; }'; } } return $styles; }
public function testBomConcatenation() { $basePath = __DIR__ . '/../../data/css'; $testModule = new ResourceLoaderFileModule(['localBasePath' => $basePath, 'styles' => ['bom.css']]); $testModule->setName('testing'); $this->assertEquals(substr(file_get_contents("{$basePath}/bom.css"), 0, 10), ".efbbbf", 'File has leading BOM'); $contextLtr = $this->getResourceLoaderContext('en', 'ltr'); $this->assertEquals($testModule->getStyles($contextLtr), ['all' => ".efbbbf_bom_char_at_start_of_file {}\n"], 'Leading BOM removed when concatenating files'); }