Beispiel #1
0
 /**
  * Executes the widget.
  * This method renders the fixtures of tests
  */
 public function run()
 {
     $content = '';
     //render the fixtures files
     $list = FileHelper::scanDirectory(Yii::getAlias($this->fixturesPath));
     foreach ($list as $file) {
         $content .= "\n" . Html::tag('div', $this->getView()->renderPhpFile($file), ['id' => $this->fixtureIdPrefix . str_replace('.', '-', basename($file))]);
     }
     return Html::tag('div', $content . "\n", $this->options);
 }
Beispiel #2
0
 /**
  * register all javascript tests
  * @param \yii\web\View $view
  */
 public function registerAssetFiles($view)
 {
     $testsPath = Yii::getAlias($this->sourcePath . DIRECTORY_SEPARATOR . $this->testBaseUrl);
     $list = FileHelper::scanDirectory($testsPath);
     foreach ($list as $file) {
         if (is_file($file)) {
             $this->js[] = $this->testBaseUrl . '/' . basename($file);
         }
     }
     parent::registerAssetFiles($view);
 }
Beispiel #3
0
 /**
  * Sets the correct skeleton for the unit tests.
  * @param CommandEvent $event
  */
 public static function initTestsSkeleton($event)
 {
     $options = $event->getComposer()->getPackage()->getExtra();
     if (!isset($options[self::EXTRA_SKELETON], $options[self::EXTRA_SKELETON]['path'])) {
         $path = 'tests/js';
     } else {
         $path = $options[self::EXTRA_SKELETON]['path'];
     }
     $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     echo "Setting init tests skeleton: {$path} ...\n";
     if (!file_exists($path)) {
         if (FileHelper::createDirectory($path)) {
             FileHelper::copyDirectory(self::getSourceSkeletonPath(), $path);
             echo "done\n";
         } else {
             echo "The directory was not found: " . $path . "\n";
         }
     } else {
         echo "{$path} directory is exists\n";
         return;
     }
 }