mockWebApplication([ 'components' => [ 'request' => [ 'scriptFile' => __DIR__ .'/baseUrl/index.php', 'scriptUrl' => '/baseUrl/index.php', ] ] ]); $view = new View(); $view->registerJsFile('@web/js/somefile.js', ['position' => View::POS_HEAD]); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertContains('', $html); $view = new View(); $view->registerJsFile('@web/js/somefile.js', ['position' => View::POS_BEGIN]); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertContains(''."\n".'', $html); $view = new View(); $view->registerJsFile('@web/js/somefile.js', ['position' => View::POS_END]); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertContains('', $html); } public function testRegisterCssFileWithAlias() { $this->mockWebApplication([ 'components' => [ 'request' => [ 'scriptFile' => __DIR__ .'/baseUrl/index.php', 'scriptUrl' => '/baseUrl/index.php', ] ] ]); $view = new View(); $view->registerCssFile('@web/css/somefile.css'); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertContains('', $html); } }