public function run(atoum\test $test)
{
$currentTestMethod = $test->getCurrentMethod();
if ($currentTestMethod !== null) {
$this->test = $test;
$this->method = $currentTestMethod;
$phpPath = $this->test->getPhpPath();
$phpCode = '<?php ' . 'ob_start();' . 'require \'' . atoum\directory . '/classes/autoloader.php\';';
$bootstrapFile = $this->test->getBootstrapFile();
if ($bootstrapFile !== null) {
$phpCode .= '$includer = new mageekguy\\atoum\\includer();' . 'try { $includer->includePath(\'' . $bootstrapFile . '\'); }' . 'catch (mageekguy\\atoum\\includer\\exception $exception)' . '{ die(\'Unable to include bootstrap file \\\'' . $bootstrapFile . '\\\'\'); }';
}
$phpCode .= 'require \'' . $this->test->getPath() . '\';' . '$test = new ' . $this->test->getClass() . '();' . '$test->setLocale(new ' . get_class($this->test->getLocale()) . '(' . $this->test->getLocale()->get() . '));' . '$test->setPhpPath(\'' . $phpPath . '\');';
if ($this->test->debugModeIsEnabled() === true) {
$phpCode .= '$test->enableDebugMode();';
}
if ($this->test->codeCoverageIsEnabled() === false) {
$phpCode .= '$test->disableCodeCoverage();';
} else {
if ($this->test->branchesAndPathsCoverageIsEnabled() === true) {
$phpCode .= '$test->enableBranchesAndPathsCoverage();';
}
$phpCode .= '$coverage = $test->getCoverage();';
foreach ($this->test->getCoverage()->getExcludedMethods() as $excludedMethod) {
$phpCode .= '$coverage->excludeMethod(\'' . $excludedMethod . '\');';
}
foreach ($this->test->getCoverage()->getExcludedClasses() as $excludedClass) {
$phpCode .= '$coverage->excludeClass(\'' . $excludedClass . '\');';
}
foreach ($this->test->getCoverage()->getExcludedNamespaces() as $excludedNamespace) {
$phpCode .= '$coverage->excludeNamespace(\'' . $excludedNamespace . '\');';
}
foreach ($this->test->getCoverage()->getExcludedDirectories() as $excludedDirectory) {
$phpCode .= '$coverage->excludeDirectory(\'' . $excludedDirectory . '\');';
}
}
if ($this->test->getMockGenerator()->undefinedMethodUsageIsAllowed() === false) {
$phpCode .= '$test->getMockGenerator()->disallowUndefinedMethodUsage();';
}
foreach ($test->getExtensions() as $extension) {
$phpCode .= '$test->addExtension(new ' . get_class($extension) . ');';
}
$phpCode .= 'ob_end_clean();' . 'mageekguy\\atoum\\scripts\\runner::disableAutorun();' . 'echo serialize($test->runTestMethod(\'' . $this->method . '\')->getScore());';
$xdebugConfig = $test->getXdebugConfig();
if ($xdebugConfig !== null) {
if (getenv('XDEBUG_CONFIG') !== false || ini_get('xdebug.remote_autostart') != 0) {
throw new exceptions\runtime('XDEBUG_CONFIG variable must not be set or value of xdebug.remote_autostart must be 0 to use xdebug with concurrent engine');
}
$this->php->XDEBUG_CONFIG = $xdebugConfig;
}
$this->php->reset()->setBinaryPath($phpPath)->run($phpCode);
}
return $this;
}