mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fixed yii\console\controllers\AssetController
looses bundle override configuration, which makes it external one
This commit is contained in:
@ -10,6 +10,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #7670: Added `UrlNormalizer` for normalizing requests with and without trailing slashes (rob006, cronfy, klimov-paul)
|
||||
- Bug #9277: Fixed `yii\console\controllers\AssetController` looses custom options of 'target' bundles (petrabarus, klimov-paul)
|
||||
- Bug #9561: Fixed `canGetProperty()` and `canSetProperty()` returns `false` for `yii\db\BaseActiveRecord` attributes (klimov-paul)
|
||||
- Bug #10567: Fixed `yii\console\controllers\AssetController` looses bundle override configuration, which makes it external one (klimov-paul)
|
||||
- Bug #11990: Fixed `yii\db\BaseActiveRecord::refresh()` may set incorrect `oldAttributes` values at some cases (only-victor)
|
||||
- Bug #12009: Do not render "for" field label attribute for active form RadioList and CheckboxList (shevchik87, samdark)
|
||||
- Bug #12068: Added missing 'LEVEL_PROFILE' for the syslog target (Mak-Di)
|
||||
|
@ -418,10 +418,9 @@ class AssetController extends Controller
|
||||
if (!$this->isBundleExternal($sourceBundle)) {
|
||||
$depends[] = $target;
|
||||
}
|
||||
$targets[$bundle] = Yii::createObject([
|
||||
'class' => strpos($bundle, '\\') !== false ? $bundle : 'yii\\web\\AssetBundle',
|
||||
'depends' => $depends,
|
||||
]);
|
||||
$targetBundle = clone $sourceBundle;
|
||||
$targetBundle->depends = $depends;
|
||||
$targets[$bundle] = $targetBundle;
|
||||
}
|
||||
|
||||
return $targets;
|
||||
|
@ -671,6 +671,69 @@ EOL;
|
||||
]);
|
||||
$this->assertEmpty($files);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testActionCompress
|
||||
*
|
||||
* @see https://github.com/yiisoft/yii2/issues/10567
|
||||
*/
|
||||
public function testActionCompressOverrideAsExternal()
|
||||
{
|
||||
// Given :
|
||||
$cssFiles = [
|
||||
'css/override_external.css' => 'body {
|
||||
padding-top: 20px;
|
||||
padding-bottom: 60px;
|
||||
}',
|
||||
];
|
||||
$this->createAssetSourceFiles($cssFiles);
|
||||
|
||||
$jsFiles = [
|
||||
'js/override_external.js' => "function test() {
|
||||
alert('Test message');
|
||||
}",
|
||||
];
|
||||
//$this->createAssetSourceFiles($cssFiles, $sourcePath);
|
||||
//$this->createAssetSourceFiles($jsFiles, $sourcePath);
|
||||
$assetBundleClassName = $this->declareAssetBundleClass([
|
||||
'class' => 'AssetOverrideExternal',
|
||||
'css' => array_keys($cssFiles),
|
||||
'js' => array_keys($jsFiles),
|
||||
]);
|
||||
|
||||
$bundles = [
|
||||
$assetBundleClassName
|
||||
];
|
||||
$bundleFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'bundle_override_as_external.php';
|
||||
|
||||
// Keep source :
|
||||
$configFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'config_override_as_external.php';
|
||||
$assetBundleOverrideConfig = [
|
||||
'sourcePath' => null,
|
||||
'basePath' => null,
|
||||
'baseUrl' => null,
|
||||
'css' => [
|
||||
'//some.cdn.com/js/override_external.css'
|
||||
],
|
||||
'js' => [
|
||||
'//some.cdn.com/js/override_external.js'
|
||||
],
|
||||
];
|
||||
$this->createCompressConfigFile($configFile, $bundles, [
|
||||
'assetManager' => [
|
||||
'bundles' => [
|
||||
$assetBundleClassName => $assetBundleOverrideConfig,
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
$this->runAssetControllerAction('compress', [$configFile, $bundleFile]);
|
||||
|
||||
$bundlesConfig = require $bundleFile;
|
||||
|
||||
$this->assertEquals($assetBundleOverrideConfig['css'], $bundlesConfig[$assetBundleClassName]['css']);
|
||||
$this->assertEquals($assetBundleOverrideConfig['js'], $bundlesConfig[$assetBundleClassName]['js']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user