in src/TestUtils/GcloudWrapper/CloudFunction.php [274:301]
public function run(array $env = [], string $port = self::DEFAULT_PORT, ?string $phpBin = null)
{
$this->localUri = 'localhost:' . $port;
$phpBin = $phpBin ?? (new PhpExecutableFinder())->find();
$router = 'vendor/google/cloud-functions-framework/router.php';
$cmd = sprintf('%s -S %s %s', $phpBin, $this->localUri, $router);
$this->process = $this->createProcess($cmd, $this->dir, array_merge($env, [
'FUNCTION_TARGET' => $this->entryPoint,
'FUNCTION_SIGNATURE_TYPE' => $this->functionSignatureType,
]));
$this->process->setTimeout(self::DEFAULT_TIMEOUT_SECONDS);
$this->process->start();
// Typically needs less than 1 second to be ready to serve requests.
// TODO: Switch to a healthcheck mechanism.
sleep(1);
// Verify the server is running.
if (!$this->process->isRunning()) {
throw new ProcessFailedException($this->process);
}
// Allow the caller to directly check on process output.
return $this->process;
}