Allow setting css options per CSS file in AssetBundle::, fixes #10158

This commit is contained in:
Mehdi Achour
2015-11-16 15:12:14 +01:00
parent 61acf28338
commit 5619e98eda
3 changed files with 45 additions and 5 deletions

View File

@@ -201,6 +201,21 @@ EOF;
$expected = <<<EOF
123<script src="/js/jquery.js"></script>4
EOF;
$this->assertEquals($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
}
public function testCssOptions()
{
$view = $this->getView();
$this->assertEmpty($view->assetBundles);
TestAssetCssOptions::register($view);
$expected = <<<EOF
1<link href="/js/default_options.css" rel="stylesheet" media="screen" hreflang="en">
<link href="/js/tv.css" rel="stylesheet" media="tv" hreflang="en">
<link href="/js/screen_and_print.css" rel="stylesheet" media="screen, print" hreflang="en">234
EOF;
$this->assertEquals($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
}
@@ -271,3 +286,15 @@ class TestAssetCircleB extends AssetBundle
'yiiunit\\framework\\web\\TestAssetCircleA'
];
}
class TestAssetCssOptions extends AssetBundle
{
public $basePath = '@testWebRoot/js';
public $baseUrl = '@testWeb/js';
public $css = [
'default_options.css',
['tv.css', 'media' => 'tv'],
['screen_and_print.css', 'media' => 'screen, print']
];
public $cssOptions = ['media' => 'screen', 'hreflang' => 'en'];
}