示例#1
0
 public function testConnectionFailLeadsToException()
 {
     $connection = new Connection('tcp://0.0.0.1:15');
     try {
         $connection->connect();
         $this->fail('Expected an exception!');
     } catch (ConnectionException $ex) {
         $this->assertContains('Could not connect to a broker', $ex->getMessage());
         $this->assertInstanceOf(ConnectionException::class, $ex->getPrevious(), 'There should be a previous exception.');
         /** @var ConnectionException $prev */
         $prev = $ex->getPrevious();
         $hostInfo = $prev->getConnectionInfo();
         $this->assertEquals('0.0.0.1', $hostInfo['host']);
         $this->assertEquals('15', $hostInfo['port']);
     }
 }
示例#2
0
 /**
  * @expectedException \Stomp\Exception\StompException
  */
 public function testWriteFrameThrowsExceptionIfNotConnected()
 {
     $connection = new Connection('tcp://localhost');
     $connection->writeFrame(new Frame());
 }
示例#3
0
 /**
  * Check if client session has ben established
  *
  * @return boolean
  */
 public function isConnected()
 {
     return !empty($this->sessionId) && $this->connection->isConnected();
 }