public function init()
 {
     $paths = array($this->basePath ?: Yii::getPathOfAlias("application.tests.fixtures"));
     foreach (array_keys(Yii::app()->modules) as $module) {
         $path = Yii::getPathOfAlias("{$module}.tests.fixtures");
         if (is_dir($path)) {
             $paths[] = $path;
         }
     }
     $schema = $this->getDbConnection()->getSchema();
     $suffix_len = strlen($this->initScriptSuffix);
     foreach ($paths as $path) {
         $dir = opendir($path);
         while ($file = readdir($dir)) {
             if (!preg_match("/\\.php\$/", $file) || substr($file, -$suffix_len) == $this->initScriptSuffix) {
                 continue;
             }
             $table = substr($file, 0, -4);
             if ($schema->getTable($table)) {
                 $this->fixtures[$table] = "{$path}/{$file}";
             }
         }
         closedir($dir);
     }
     parent::init();
 }
Example #2
0
 public function init()
 {
     parent::init();
     foreach (Yii::app()->moduleManager->getInstalledModules(true, false) as $moduleId => $module) {
         $moduleFixturePath = $module->getPath() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'fixtures';
         if (is_dir($moduleFixturePath)) {
             $this->moduleBasePaths[] = $moduleFixturePath;
             $this->prepareModule($moduleFixturePath);
         }
     }
 }