public function testAssetRegister() { $view = Yii::$app->getView(); $this->assertEmpty($view->assetBundles); RadioButtonGroupAsset::register($view); $this->assertEquals(4, count($view->assetBundles)); $this->assertArrayHasKey('yii\\web\\JqueryAsset', $view->assetBundles); $this->assertTrue($view->assetBundles['webtoolsnz\\widgets\\RadioButtonGroupAsset'] instanceof AssetBundle); $content = $view->renderFile('@tests/views/layouts/raw.php'); $this->assertContains('bootstrap.css', $content); $this->assertContains('radio-button-group.css', $content); $this->assertContains('bootstrap.js', $content); $this->assertContains('radio-button-group.js', $content); }
/** * Registers widget assets */ protected function registerClientScript() { $view = $this->getView(); RadioButtonGroupAsset::register($view); $id = $this->widgetId; $options = Json::encode($this->itemOptions); $js[] = "jQuery('#{$id}').radioButtonGroup({$options});"; $view->registerJs(implode("\n", $js)); }