public function runInHttpMode($file) { $server = new HttpServer('localhost', 56789, $this->getFilePath($file)); $server->start(); $client = new HttpClient(); $request = new HttpRequest(HttpRequestMethod::GET, new Url('localhost:56789')); $response = $client->send($request); $server->stop(); return $response->getContent(); }
public function test_server_logging() { $server = new HttpServer('localhost', 6789, __DIR__); $logFile = tempnam(sys_get_temp_dir(), 'php'); $server->setLogFile($logFile); $server->start(); file_get_contents('http://localhost:6789/test?first'); file_get_contents('http://localhost:6789/test?second'); $server->stop(); $lines = explode("\n", file_get_contents($logFile)); $this->assertRegExp('/first$/', $lines[0]); $this->assertRegExp('/second$/', $lines[1]); unlink($logFile); }
public function tearDown() { $this->server->stop(); }