Beispiel #1
0
 public function run()
 {
     require_once BP . '/lib/autoload.php';
     $this->_validate();
     $this->_init();
     try {
         foreach (Mage::getConfig()->loadModules()->getNode('modules')->children() as $moduleName => $module) {
             $featureDir = Mage::getConfig()->getModuleDir('', $moduleName) . DS . 'Test' . DS . 'features';
             $runBehat = false;
             //only run behat once we have found at least one feature file
             if (is_dir($featureDir)) {
                 foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($featureDir)) as $file) {
                     if (pathinfo($file->getFilename(), PATHINFO_EXTENSION) == 'feature') {
                         $runBehat = true;
                         break;
                     }
                 }
             }
             if ($runBehat) {
                 //TODO: work out a way to pass this through the application
                 Mage::register('magebehat/current_module', $moduleName);
                 $app = new Behat\Behat\Console\BehatApplication(BEHAT_VERSION);
                 $input = new StringInput($this->getArgs($moduleName) . $featureDir);
                 $app->setAutoExit(false);
                 $app->run($input);
                 Mage::unregister('magebehat/current_module');
             }
         }
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }