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);
}
public function testICanGetTestSuitesWithMultipleTests() { // tests $filename = $this->directory . 'ExampleTest1.php'; $content = '<?php namespace vendor\\project\\tests\\units; require_once "ExampleSrc1.php"; use \\mageekguy\\atoum; use \\vendor\\project; class helloWorld1 extends atoum\\test { public function testSay() { $this->string("1")->isEqualTo("2") ; } } '; file_put_contents($filename, $content); $filename = $this->directory . 'ExampleTest2.php'; $content = '<?php namespace vendor\\project\\tests\\units; require_once "ExampleSrc2.php"; use \\mageekguy\\atoum; use \\vendor\\project; class helloWorld2 extends atoum\\test { public function testSay() { $this->string("1")->isEqualTo("1") ; } } '; file_put_contents($filename, $content); // sources $filename = $this->directory . 'ExampleSrc1.php'; $content = '<?php namespace vendor\\project; class helloWorld1 { public function say() { return "Hello World!"; } public function foo() { return "Hello foo"; } } '; file_put_contents($filename, $content); $filename = $this->directory . 'ExampleSrc2.php'; $content = '<?php namespace vendor\\project; class helloWorld2 { public function say() { return "Hello World!"; } public function foo() { return "Hello foo"; } } '; file_put_contents($filename, $content); $runner = new AtoumAdapter($this->binary, $this->directory); $logFile = tempnam(sys_get_temp_dir(), 'unit-test'); $runner->run(null, array(), $logFile); $collection = $runner->getSuiteResult($logFile); $this->assertInstanceOf('\\Hal\\MutaTesting\\Test\\UnitCollectionInterface', $collection); $this->assertEquals(2, sizeof($collection->all())); $unit = $collection->getByFile($this->directory . 'ExampleTest1.php'); $this->assertInstanceOf('\\Hal\\MutaTesting\\Test\\UnitInterface', $unit); }