public function testDuplicateAssetFile() { $view = $this->getView(); $this->assertEmpty($view->assetBundles); TestSimpleAsset::register($view); $this->assertEquals(1, count($view->assetBundles)); $this->assertArrayHasKey('yiiunit\\framework\\web\\TestSimpleAsset', $view->assetBundles); $this->assertTrue($view->assetBundles['yiiunit\\framework\\web\\TestSimpleAsset'] instanceof AssetBundle); // register TestJqueryAsset which also has the jquery.js TestJqueryAsset::register($view); $expected = <<<EOF 123<script src="/js/jquery.js"></script>4 EOF; $this->assertEquals($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php')); }
/** * @dataProvider positionProvider */ public function testPositionDependencyConflict($pos, $jqAlreadyRegistered) { $view = $this->getView(); $view->getAssetManager()->bundles['yiiunit\\framework\\web\\TestAssetBundle'] = ['jsOptions' => ['position' => $pos - 1]]; $view->getAssetManager()->bundles['yiiunit\\framework\\web\\TestJqueryAsset'] = ['jsOptions' => ['position' => $pos]]; $this->assertEmpty($view->assetBundles); if ($jqAlreadyRegistered) { TestJqueryAsset::register($view); } $this->setExpectedException('yii\\base\\InvalidConfigException'); TestAssetBundle::register($view); }