public function setUp()
 {
     $this->server = new HttpServer('localhost', 8080, __DIR__ . '/helper/server.php');
     $this->server->disableOutput();
     $this->server->start();
     $this->client = new HttpClient();
 }
Exemple #2
0
 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();
 }
Exemple #3
0
 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);
 }