Inheritance: implements Hal\MutaTesting\Runner\Adapter\AdapterInterface
示例#1
0
 public function testICanGetFIleToPrependInOrderToMockSources()
 {
     $mutation = $this->getMock('\\Hal\\MutaTesting\\Mutation\\MutationInterface');
     $tokens = $this->getMock('\\Hal\\Component\\Token\\TokenCollection', array(), array(array()));
     $mutation->expects($this->any())->method('getTokens')->will($this->returnValue($tokens));
     $adapter = new BaseAdapter(null, null);
     $filename = $adapter->createFileSystemMock($mutation);
     $this->assertTrue(file_exists($filename));
     $this->assertContains('No syntax errors detected', `php -l {$filename}`);
     // clean up
     unlink($filename);
 }
示例#2
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);
 }
示例#3
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);
 }