diff --git a/tests/framework/web/AssetBundleTest.php b/tests/framework/web/AssetBundleTest.php index 333e8a5..267cdb9 100644 --- a/tests/framework/web/AssetBundleTest.php +++ b/tests/framework/web/AssetBundleTest.php @@ -346,6 +346,7 @@ EOF; public function registerFileDataProvider() { return [ + // JS files registration [ 'js', '@web/assetSources/js/jquery.js', true, '1234', @@ -374,6 +375,8 @@ EOF; 'js', '/assetSources/js/jquery.js', false, '1234', ], + + // CSS file registration [ 'css', '@web/assetSources/css/stub.css', true, '1234', @@ -402,6 +405,23 @@ EOF; 'css', '/assetSources/css/stub.css', false, '1234', ], + + // Custom `@web` aliases + [ + 'js', '@web/assetSources/js/jquery.js', true, + '1234', + '/backend' + ], + [ + 'js', '@web/assetSources/js/missing-file.js', true, + '1234', + '/backend' + ], + [ + 'css', '@web/assetSources/css/stub.css', false, + '1234', + '/en/blog/backend' + ], ]; } @@ -412,12 +432,21 @@ EOF; * @param string bool $appendTimestamp * @param string $expectedRegExp */ - public function testRegisterFileAppendTimestamp($type, $path, $appendTimestamp, $expectedRegExp) + public function testRegisterFileAppendTimestamp($type, $path, $appendTimestamp, $expectedRegExp, $webAlias = null) { + $originalAlias = Yii::getAlias('@web'); + if ($webAlias === null) { + $webAlias = $originalAlias; + } + Yii::setAlias('@web', $webAlias); + + $view = $this->getView(['appendTimestamp' => $appendTimestamp]); $method = 'register' . ucfirst($type) . 'File'; $view->$method($path); $this->assertRegExp('#' . $expectedRegExp . '#', $view->renderFile('@yiiunit/data/views/rawlayout.php')); + + Yii::setAlias('@web', $originalAlias); } }