mageekguy\atoum\scripts\runner::doRun PHP Метод

doRun() защищенный Метод

protected doRun ( )
    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));
                }
            }
            $autoloaderFile = $this->runner->getAutoloaderFile();
            if ($autoloaderFile !== null) {
                $this->verbose($this->locale->_('Using \'%s\' autoloader file…', $autoloaderFile));
            }
            $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;
    }

Usage Example

Пример #1
0
 protected function doRun()
 {
     if (sizeof($this->getReports()) === 0) {
         $this->addDefaultReport();
     }
     switch ($this->reportFormat) {
         case 'xml':
         case 'clover':
             $writer = new atoum\writers\file($this->reportOutputPathIsSet()->reportOutputPath);
             $report = new atoum\reports\asynchronous\clover();
             $this->addReport($report->addWriter($writer));
             break;
         case 'html':
             $field = new atoum\report\fields\runner\coverage\html('Code coverage', $this->reportOutputPathIsSet()->reportOutputPath);
             $field->setRootUrl('file://' . realpath(rtrim($this->reportOutputPathIsSet()->reportOutputPath, DIRECTORY_SEPARATOR)) . '/index.html');
             current($this->getReports())->addField($field);
             break;
         case 'treemap':
             $field = new atoum\report\fields\runner\coverage\treemap('Code coverage treemap', $this->reportOutputPathIsSet()->reportOutputPath);
             $field->setTreemapUrl('file://' . realpath(rtrim($this->reportOutputPathIsSet()->reportOutputPath, DIRECTORY_SEPARATOR)) . '/index.html');
             current($this->getReports())->addField($field);
             break;
         default:
             throw new exceptions\logic\invalidArgument('Invalid format for coverage report');
     }
     return parent::doRun();
 }