コード例 #1
0
ファイル: runner.php プロジェクト: eroluysal/atoum
 protected function doRun()
 {
     parent::doRun();
     if ($this->argumentsParser->hasFoundArguments() === false) {
         $this->argumentsParser->parse($this, $this->defaultArguments);
     }
     if (sizeof($this->runner->getTestPaths()) <= 0 && sizeof($this->runner->getDeclaredTestClasses()) <= 0) {
         $this->writeError($this->locale->_('No test found'))->help();
     } else {
         $arguments = $this->argumentsParser->getValues();
         if (sizeof($arguments) <= 0) {
             $this->verbose($this->locale->_('Using no CLI argument…'));
         } else {
             $this->verbose(sprintf($this->locale->__('Using %s CLI argument…', 'Using %s arguments…', sizeof($arguments)), $this->argumentsParser));
         }
         if (sizeof($this->configFiles) > 0) {
             foreach ($this->configFiles as $configFile) {
                 $this->verbose($this->locale->_('Using \'%s\' configuration file…', $configFile));
             }
         }
         $bootstrapFile = $this->runner->getBootstrapFile();
         if ($bootstrapFile !== null) {
             $this->verbose($this->locale->_('Using \'%s\' bootstrap file…', $bootstrapFile));
         }
         foreach (atoum\autoloader::getRegisteredAutoloaders() as $autoloader) {
             $this->verbose($this->locale->_('Using \'%s\' autoloader cache file…', $autoloader->getCacheFileForInstance()));
         }
         foreach ($this->runner->getTestPaths() as $testPath) {
             $this->verbose($this->locale->_('Using \'%s\' test file…', $testPath), 2);
         }
         if ($this->loop === true) {
             $this->loop();
         } else {
             if ($this->runner->hasReports() === false) {
                 $this->addDefaultReport();
             }
             $methods = $this->methods;
             $oldFailMethods = array();
             if ($this->scoreFile !== null && ($scoreFileContents = @file_get_contents($this->scoreFile)) !== false && ($oldScore = @unserialize($scoreFileContents)) instanceof atoum\score) {
                 $oldFailMethods = self::getFailMethods($oldScore);
                 if ($oldFailMethods) {
                     $methods = $oldFailMethods;
                 }
             }
             $newScore = $this->runner->run($this->namespaces, $this->tags, $this->getClassesOf($methods), $methods);
             $this->saveScore($newScore);
             if ($oldFailMethods && sizeof(self::getFailMethods($newScore)) <= 0) {
                 $testMethods = $this->runner->getTestMethods($this->namespaces, $this->tags, $this->methods);
                 if (sizeof($testMethods) > 1 || sizeof(current($testMethods)) > 1) {
                     $this->saveScore($this->runner->run($this->namespaces, $this->tags, $this->getClassesOf($this->methods), $this->methods));
                 }
             }
         }
     }
     return $this;
 }