Example #1
0
 public function testClose()
 {
     // Start a NEW dedicated server for this test
     $cmd = 'php examples/echoserver.php';
     $outputfile = 'build/serveroutput_close.txt';
     $pidfile = 'build/server_close.pid';
     exec(sprintf("%s > %s 2>&1 & echo \$! >> %s", $cmd, $outputfile, $pidfile));
     usleep(500000);
     $port = trim(file_get_contents($outputfile));
     $ws = new Client('ws://localhost:' . $port . '/' . $this->test_id);
     $ws->send('exit');
     $response = $ws->receive();
     $this->assertEquals('ttfn', $response);
     $this->assertEquals(1000, $ws->getCloseStatus());
     $this->assertFalse($ws->isConnected());
 }