protected static function _initDefaults()
 {
     if (self::$has_defaults) {
         return;
     }
     self::$has_defaults = true;
 }
 static function getFileFilter()
 {
     if (!is_object(self::$file_filter)) {
         self::setFileFilter(lmbTestOptions::get('file_filter'));
     }
     return self::$file_filter;
 }
 function paintMethodStart($test_name)
 {
     parent::paintMethodStart($test_name);
     if (lmbTestOptions::get('verbose')) {
         print "===== [{$test_name}] =====\n";
     }
 }
 protected function _prepareTestCase($test)
 {
     require_once $this->file;
     $candidates = $this->_getClassesDefinedInFile();
     $loader = new SimpleFileLoader();
     foreach ($loader->selectRunnableTests($candidates) as $class) {
         if ($this->_isFiltered($class)) {
             continue;
         }
         $case = new $class();
         $case->filter(lmbTestOptions::get('methods_filter'));
         $test->addTestCase($case);
         //a dirty SimpleTest PHP4 compatibility hack
         //otherwise $case is overwrittne since it is a reference
         unset($case);
     }
 }
 function getTestLabel()
 {
     return 'All tests in "' . implode(';', $this->paths) . '"(filter "' . lmbTestOptions::get('file_filter') . '")';
 }
Beispiel #6
0
 protected function _doRun()
 {
     $short_opts = self::getShortOpts();
     $long_opts = self::getLongOpts();
     lmbTestGetopt::defineAndExtractConstants($this->argv);
     try {
         if ($this->posix_opts) {
             $options = lmbTestGetopt::getopt($this->argv, $short_opts, $long_opts);
         } else {
             $options = lmbTestGetopt::getopt2($this->argv, $short_opts, $long_opts);
         }
     } catch (Exception $e) {
         $this->_help(1);
     }
     $config_file = null;
     $cover_include = '';
     $cover_exclude = '';
     $cover_report_dir = null;
     foreach ($options[0] as $option) {
         switch ($option[0]) {
             case 'h':
             case '--help':
                 $this->_help(0);
                 break;
             case 'V':
             case '--verbose':
                 lmbTestOptions::set('verbose', true);
                 break;
             case 'v':
             case '--version':
                 $this->_version();
                 break;
             case 'c':
             case '--config':
                 $config_file = $option[1];
                 break;
             case 'I':
             case '--include':
                 lmbTestOptions::set('file_filter', $option[1]);
                 break;
             case 'G':
             case '--groups':
                 lmbTestOptions::set('groups_filter', array_map('trim', explode(',', trim($option[1]))));
                 break;
             case 'T':
             case '--tests':
                 lmbTestOptions::set('tests_filter', array_map('trim', explode(',', trim($option[1]))));
                 break;
             case 'M':
             case '--methods':
                 lmbTestOptions::set('methods_filter', array_map('trim', explode(',', trim($option[1]))));
                 break;
             case 'C':
             case '--cover':
                 $cover_include = $option[1];
                 break;
             case '--cover-report':
                 $cover_report_dir = $option[1];
                 break;
             case '--cover-exclude':
                 $cover_exclude = $option[1];
                 break;
         }
     }
     if (!$config_file) {
         $config_file = getenv('LIMB_TESTS_RUNNER_CONFIG');
     }
     if ($config_file) {
         if (!($php = @file_get_contents(realpath($config_file)))) {
             $this->_error("Could not read configuration file '{$config_file}'\n");
         }
         if (!$this->_phpLint($php, $error)) {
             $this->_error("Configuration file '{$config_file}' is invalid(check syntax)\n{$error}");
         }
         if (!(include_once realpath($config_file))) {
             $this->_error("Could not include configuration file '{$config_file}'\n");
         }
     }
     if (!is_array($options[1]) || !count($options[1])) {
         $paths = array('.');
     } else {
         $paths = $options[1];
     }
     if (!$cover_report_dir && defined('LIMB_TESTS_RUNNER_COVERAGE_REPORT_DIR')) {
         $cover_report_dir = LIMB_TESTS_RUNNER_COVERAGE_REPORT_DIR;
     }
     require_once dirname(__FILE__) . '/lmbTestRunner.class.php';
     $runner = new lmbTestRunner();
     if ($this->reporter) {
         $runner->setReporter($this->reporter);
     }
     if ($cover_include) {
         $runner->useCoverage($cover_include, $cover_exclude, $cover_report_dir);
     }
     try {
         require_once dirname(__FILE__) . '/lmbTestTreeGlobNode.class.php';
         $node = new lmbTestTreeGlobNode($paths);
         $res = $runner->run($node);
     } catch (lmbTestUserException $e) {
         $this->_error($e->getMessage());
     } catch (Exception $e) {
         $this->_error($e->__toString());
     }
     return $res;
 }