run() публичный Метод

Run tests
public run ( string $path = null, array $options = [], string $logFile = null, string $prependFile = null, callable $callback = null ) : string
$path string
$options array
$logFile string
$prependFile string
$callback callable
Результат string $output
Пример #1
0
 /**
  * @inherit
  */
 public function run($path = null, array $options = array(), $logFile = null, $prependFile = null, callable $callback = null)
 {
     if (!is_null($logFile)) {
         array_push($options, sprintf('--log-junit %s', $logFile));
     }
     if (!is_null($prependFile)) {
         // We cannot use php directive auto_prepend_file :
         // PHPUnit doesn't tun test in a separate process by default
         // see @link https://github.com/sebastianbergmann/phpunit/issues/930
         //
         // all the following lines should be replaced with the commented line if
         // PHPUnit change its behavior
         //
         // $options = array(sprintf('-d auto_prepend_file=%s', $bootstrapName));
         array_push($options, sprintf('--bootstrap %s', $prependFile));
         foreach ($this->getOptions() as $option) {
             $filename = false;
             if (preg_match('!-c\\s*(.*)!', $option, $matches)) {
                 $configFile = $matches[1];
                 $xml = simplexml_load_file($configFile);
                 $filename = (string) $xml['bootstrap'];
             }
             if (preg_match('!--configuration\\s*(.*)!', $option, $matches)) {
                 $configFile = $matches[1];
                 $xml = simplexml_load_file($configFile);
                 $filename = (string) $xml['bootstrap'];
             }
             if (preg_match('!--bootstrap\\s*(.*)!', $option, $matches)) {
                 $filename = $matches[1];
             }
             if ($filename) {
                 $filename = $origine = dirname($configFile) . DIRECTORY_SEPARATOR . $filename;
                 $content = file_get_contents($filename);
                 $filename = tempnam(sys_get_temp_dir(), 'tmp-botstrap');
                 $content = str_replace('__FILE__', "'{$origine}'", $content);
                 $content = str_replace('__DIR__', "'" . dirname($origine) . "'", $content);
                 file_put_contents($filename, $content);
                 file_put_contents($prependFile, sprintf("<?php require_once '%s';?>", $filename), FILE_APPEND);
             }
         }
     }
     return parent::run($path, $options, null, null, $callback);
 }
Пример #2
0
 /**
  * @inherit
  */
 public function run($path = null, array $options = array(), $logFile = null, $prependFile = null, callable $callback = null)
 {
     // path
     if (null !== $path) {
         if (is_dir($path)) {
             $options[] = sprintf('-d %s', $path);
         } else {
             $options[] = sprintf('-f %s', $path);
         }
         $path = null;
     }
     if (!is_null($logFile)) {
         $bin = trim(preg_replace('!(php\\s+)!i', '', $this->binary));
         $content = sprintf('?><?php require_once "%s"; ', realpath($bin) ? realpath($bin) : getcwd() . $this->binary) . sprintf('$writer = new \\mageekguy\\atoum\\writers\\file("%s");', $logFile) . '$xunit = new \\mageekguy\\atoum\\reports\\asynchronous\\xunit();' . '$xunit->addWriter($writer);' . '$runner->addReport($xunit);' . '?>';
         $this->addInConfiguration($content, $options);
     }
     if (!is_null($prependFile)) {
         $this->addInBootstrap(null, $options, $prependFile);
     }
     return parent::run(null, $options, null, null, $callback);
 }