/**
  * @param string $language
  * @dataProvider languageDataProvider
  */
 public function testBundleHasFile2($language)
 {
     $assetManager = Yii::$app->getAssetManager();
     $assetManager->bundles[TinymceLanguageAsset::className()] = ['language' => $language];
     $bundle = $assetManager->getBundle(TinymceLanguageAsset::className());
     $this->assertInstanceOf('yii\\tinymce\\TinymceLanguageAsset', $bundle);
     $this->assertArrayHasKey(0, $bundle->depends);
     $this->assertEquals('yii\\tinymce\\TinymceAsset', $bundle->depends[0]);
     $this->assertArrayHasKey(0, $bundle->js);
     $this->assertFileExists($bundle->basePath . DIRECTORY_SEPARATOR . $bundle->js[0]);
 }
Esempio n. 2
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         $output = Html::activeTextarea($this->model, $this->attribute, $this->options);
     } else {
         $output = Html::textarea($this->name, $this->value, $this->options);
     }
     $js = 'jQuery(\'#' . $this->options['id'] . '\').tinymce(' . Json::htmlEncode($this->clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         TinymceAsset::register($view);
         TinymceLanguageAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
Esempio n. 3
0
 /**
  * @param int $mode
  * @param string $actual
  * @param string $expectedHtml
  * @param string $expectedJs
  */
 protected function checkExpected($mode, $actual, $expectedHtml, $expectedJs)
 {
     switch ($mode) {
         case static::MODE_MODEL_ATTRIBUTE:
         case static::MODE_MODEL_ATTRIBUTE_VALUE:
             $expectedHtml = '<div class="form-group field-testform-text">' . "\n" . $expectedHtml . "\n" . '</div>';
         case static::MODE_NAME_VALUE:
             $this->assertEquals($expectedHtml, $actual);
             $view = Yii::$app->getView();
             $this->assertArrayHasKey(TinymceAsset::className(), $view->assetBundles);
             $this->assertArrayHasKey(TinymceLanguageAsset::className(), $view->assetBundles);
             $this->assertArrayHasKey(View::POS_READY, $view->js);
             $jsKey = md5($expectedJs);
             $this->assertArrayHasKey($jsKey, $view->js[View::POS_READY]);
             $this->assertEquals($expectedJs, $view->js[View::POS_READY][$jsKey]);
             return;
         case static::MODE_NAME_VALUE_AJAX:
             $expectedHtml .= '<script>' . $expectedJs . '</script>';
             $this->assertEquals($expectedHtml, $actual);
             return;
         case static::MODE_MODEL_ATTRIBUTE_AJAX:
         case static::MODE_MODEL_ATTRIBUTE_VALUE_AJAX:
             $expectedHtml .= '<script>' . $expectedJs . '</script>';
             $expectedHtml = '<div class="form-group field-testform-text">' . "\n" . $expectedHtml . "\n" . '</div>';
             $this->assertEquals($expectedHtml, $actual);
             return;
     }
     throw new Exception();
 }