function TemplateProjectTestBase::instantiateServer
Overrides BuildTestBase::instantiateServer
1 call to TemplateProjectTestBase::instantiateServer()
- TemplateProjectTestBase::createTestProject in core/
modules/ package_manager/ tests/ src/ Build/ TemplateProjectTestBase.php - Creates a test project from a given template and installs Drupal.
File
-
core/
modules/ package_manager/ tests/ src/ Build/ TemplateProjectTestBase.php, line 147
Class
- TemplateProjectTestBase
- Base class for tests which create a test site from a core project template.
Namespace
Drupal\Tests\package_manager\BuildCode
protected function instantiateServer($port, $working_dir = NULL) {
$working_dir = $working_dir ?: $this->webRoot;
$finder = new PhpExecutableFinder();
$working_path = $this->getWorkingPath($working_dir);
$server = [
$finder->find(),
'-S',
'127.0.0.1:' . $port,
'-d max_execution_time=' . static::MAX_EXECUTION_TIME,
'-d disable_functions=set_time_limit',
'-t',
$working_path,
];
if (file_exists($working_path . DIRECTORY_SEPARATOR . '.ht.router.php')) {
$server[] = $working_path . DIRECTORY_SEPARATOR . '.ht.router.php';
}
$ps = new Process($server, $working_path);
$ps->setIdleTimeout(30)
->setTimeout(30)
->start(function ($output_type, $output) : void {
if ($output_type === Process::ERR) {
$this->serverErrorLog .= $output;
}
});
// Wait until the web server has started. It is started if the port is no
// longer available.
for ($i = 0; $i < 50; $i++) {
usleep(100000);
if (!$this->checkPortIsAvailable($port)) {
return $ps;
}
}
throw new \RuntimeException(sprintf("Unable to start the web server.\nCMD: %s \nCODE: %d\nSTATUS: %s\nOUTPUT:\n%s\n\nERROR OUTPUT:\n%s", $ps->getCommandLine(), $ps->getExitCode(), $ps->getStatus(), $ps->getOutput(), $ps->getErrorOutput()));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.