function TestRunner::runInSeparateProcess
Throws
\SebastianBergmann\Template\InvalidArgumentException
MoreThanOneDataSetFromDataProviderException
StaticAnalysisCacheNotConfiguredException
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ TestRunner.php, line 260
Class
- TestRunner
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\FrameworkCode
public function runInSeparateProcess(TestCase $test, bool $runEntireClass, bool $preserveGlobalState) : void {
$class = new ReflectionClass($test);
if ($runEntireClass) {
$template = new Template(__DIR__ . '/../Util/PHP/Template/TestCaseClass.tpl');
}
else {
$template = new Template(__DIR__ . '/../Util/PHP/Template/TestCaseMethod.tpl');
}
$bootstrap = '';
$constants = '';
$globals = '';
$includedFiles = '';
$iniSettings = '';
if (ConfigurationRegistry::get()->hasBootstrap()) {
$bootstrap = ConfigurationRegistry::get()->bootstrap();
}
if ($preserveGlobalState) {
$constants = GlobalState::getConstantsAsString();
$globals = GlobalState::getGlobalsAsString();
$includedFiles = GlobalState::getIncludedFilesAsString();
$iniSettings = GlobalState::getIniSettingsAsString();
}
$exportObjects = Event\Facade::emitter()->exportsObjects() ? 'true' : 'false';
$coverage = CodeCoverage::instance()->isActive() ? 'true' : 'false';
$linesToBeIgnored = var_export(CodeCoverage::instance()->linesToBeIgnored(), true);
if (defined('PHPUNIT_COMPOSER_INSTALL')) {
$composerAutoload = var_export(PHPUNIT_COMPOSER_INSTALL, true);
}
else {
$composerAutoload = '\'\'';
}
if (defined('__PHPUNIT_PHAR__')) {
$phar = var_export(__PHPUNIT_PHAR__, true);
}
else {
$phar = '\'\'';
}
$data = var_export(serialize($test->providedData()), true);
$dataName = var_export($test->dataName(), true);
$dependencyInput = var_export(serialize($test->dependencyInput()), true);
$includePath = var_export(get_include_path(), true);
// must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC
// the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences
$data = "'." . $data . ".'";
$dataName = "'.(" . $dataName . ").'";
$dependencyInput = "'." . $dependencyInput . ".'";
$includePath = "'." . $includePath . ".'";
$offset = hrtime();
$serializedConfiguration = $this->saveConfigurationForChildProcess();
$processResultFile = tempnam(sys_get_temp_dir(), 'phpunit_');
$var = [
'bootstrap' => $bootstrap,
'composerAutoload' => $composerAutoload,
'phar' => $phar,
'filename' => $class->getFileName(),
'className' => $class->getName(),
'collectCodeCoverageInformation' => $coverage,
'linesToBeIgnored' => $linesToBeIgnored,
'data' => $data,
'dataName' => $dataName,
'dependencyInput' => $dependencyInput,
'constants' => $constants,
'globals' => $globals,
'include_path' => $includePath,
'included_files' => $includedFiles,
'iniSettings' => $iniSettings,
'name' => $test->name(),
'offsetSeconds' => $offset[0],
'offsetNanoseconds' => $offset[1],
'serializedConfiguration' => $serializedConfiguration,
'processResultFile' => $processResultFile,
'exportObjects' => $exportObjects,
];
if (!$runEntireClass) {
$var['methodName'] = $test->name();
}
$template->setVar($var);
$php = AbstractPhpProcess::factory();
$php->runTestJob($template->render(), $test, $processResultFile);
@unlink($serializedConfiguration);
}