Esempio n. 1
0
 public function getTests()
 {
     $config = \Yii::$app->controller->module->params;
     foreach ($config['tests'] as $type => $active) {
         // Get out of the loop in case the type is deactivated in config
         if (!$active) {
             break;
         }
         // Configure the file iterator
         $directory = new \RecursiveDirectoryIterator("{$this->configuration['paths']['tests']}/{$type}/", \RecursiveDirectoryIterator::KEY_AS_FILENAME | \RecursiveDirectoryIterator::CURRENT_AS_FILEINFO);
         $phpfiles = new \RegexIterator(new \RecursiveIteratorIterator($directory), '/^.+(Cept|Cest|Test)\\.php$/i', \RegexIterator::MATCH, \RegexIterator::USE_KEY);
         foreach ($phpfiles as $file) {
             if (!in_array($file->getFilename(), $config['ignore']) && $file->isFile()) {
                 $test = new Test();
                 $test->initialize($type, $file);
                 array_push($this->tests, $test);
                 unset($test);
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Given a test, run the Codeception test.
  *
  * @param  Test $test Current test to Run.
  * @return Test $test Updated test with log and result.
  */
 public function run(Test $test)
 {
     // Get the full command path to run the test.
     $command = $this->getCommandPath($test->getType(), $test->getFilename());
     // Attempt to set the correct writes to Codeceptions Log path.
     @chmod($this->getLogPath(), 0777);
     // Run the helper function (as it's not specific to Codeception)
     // which returns the result of running the terminal command into an array.
     $output = run_terminal_command($command);
     // Add the log to the test which also checks to see if there was a pass/fail.
     $test->setLog($output);
     return $test;
 }