/** * Start up the built in httpd in php-5.4 * * @BeforeSuite */ public static function setUp(SuiteEvent $event) { $params = $event->getContextParameters(); $url = parse_url($params['url']); $port = !empty($url['port']) ? $url['port'] : 80; if (self::canConnectToHttpd($url['host'], $port)) { throw new RuntimeException('Something is already running on ' . $params['url'] . '. Aborting tests.'); } $pid = self::startBuiltInHttpd($url['host'], $port, $params['documentRoot'], $params['router'], $params['httpdLog']); if (!$pid) { // Could not start the httpd for some reason throw new RuntimeException('Could not start the web server'); } // Try to connect $start = microtime(true); $connected = false; while (microtime(true) - $start <= (int) $params['timeout']) { if (self::canConnectToHttpd($url['host'], $port)) { $connected = true; break; } } if (!$connected) { throw new RuntimeException(sprintf('Could not connect to the web server within the given timeframe (%d second(s))', $params['timeout'])); } // Register a shutdown function that will automatically shut down the httpd register_shutdown_function(function () use($pid) { exec('kill ' . $pid); }); self::$testSessionId = uniqid('', true); }
public function __construct($url, $documentRoot, $router, $httpdLog, $timeout) { parent::__construct($url, $documentRoot, $router, $httpdLog, $timeout); $this->elasticsearch = ClientBuilder::create()->build(); $this->images = []; }
/** * {@inheritdoc} */ public function setRequestHeader($header, $value) { if ($value === 'current-timestamp') { $value = gmdate('Y-m-d\\TH:i:s\\Z'); } parent::setRequestHeader($header, $value); }