コード例 #1
0
 /**
  * Tests that the StreamSocketConnection class can handle errors.
  */
 public function testFailedRead()
 {
     // Create sockets and connection classes
     $sockets = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
     stream_set_blocking($sockets[0], 0);
     stream_set_blocking($sockets[1], 0);
     $streamSocket1 = new StreamSocketConnection($sockets[0]);
     $streamSocket2 = new StreamSocketConnection($sockets[1]);
     $streamSocket2->close();
     try {
         $streamSocket1->read(5);
         $this->fail('Should have thrown exception');
     } catch (ConnectionException $exception) {
         $this->assertEquals('fread failed', $exception->getMessage());
     }
     $streamSocket1->close();
 }