Пример #1
0
 /**
  * creating socket for invalid scheme should fail
  */
 public function testCreateFromStringInvalid()
 {
     $address = 'invalid://whatever';
     try {
         $this->factory->createFromString($address, $scheme);
     } catch (Exception $e) {
         return;
     }
     $this->fail('Creating socket for invalid scheme should fail');
 }
Пример #2
0
 /**
  * @depends testServerNonBlocking
  */
 public function testServerNonBlockingAcceptClient(Socket $server)
 {
     // create local client connected to the given server
     $client = $this->factory->createClient($server->getSockName());
     // client connected, so we can not accept() this socket
     $peer = $server->accept();
     // peer should be writable right away
     $this->assertTrue($peer->selectWrite(0.1));
     $peer->write('test');
     // expect to receive the message in one chunk
     $this->assertEquals('test', $client->read(100));
     // disconnect local client
     $client->close();
     // disconnection should be detected withing 1s max
     $this->assertTrue($peer->selectRead(1.0));
     $peer->close();
 }