/** * Tests Stomp byte messages */ public function testByteMessages() { if (!$this->stomp->isConnected()) { $this->stomp->connect(); } $body = 'test'; $mapMessage = new Bytes($body); $this->stomp->send('/queue/bytes', $mapMessage); $simpleStomp = new SimpleStomp($this->stomp); $simpleStomp->subscribe('/queue/bytes'); $msg = $this->stomp->readFrame(); $this->assertEquals($msg->body, $body); $this->stomp->disconnect(); }
/** * Tests Stomp byte messages */ public function testByteMessages() { if (!$this->Stomp->isConnected()) { $this->Stomp->connect(); } $body = 'test'; $mapMessage = new Bytes($body); $this->Stomp->send($this->queue, $mapMessage); $this->Stomp->disconnect(true); $this->simpleStomp->subscribe($this->queue, 'mysubid'); $msg = $this->Stomp->readFrame(); $this->assertEquals($msg->body, $body); $this->simpleStomp->ack($msg); $this->Stomp->disconnect(); }
/** * Cleans up the environment after running a test. */ protected function tearDown() { $this->Stomp->disconnect(); $this->Stomp = null; parent::tearDown(); }
public function testDisconnectWillCallConnectionDisconnectEvenWhenWriteFails() { $connection = $this->getMockBuilder(Connection::class)->setConstructorArgs(['tcp://127.0.0.1:'])->setMethods(['disconnect', 'readFrame', 'writeFrame', 'isConnected'])->getMock(); $connection->expects($this->any())->method('isConnected')->willReturn(true); $connection->expects($this->once())->method('readFrame')->will($this->returnValue(new Frame('CONNECTED', ['session' => 'id', 'server' => 'activemq']))); $connection->expects($this->once())->method('disconnect'); $stomp = new Client($connection); $stomp->connect(); $connection->expects($this->once())->method('writeFrame')->will($this->throwException(new StompException('Test: Writing frame failed.'))); $stomp->disconnect(); // ensure that instance is not destroyed before mock assertions are done // (calling destruct would invoke disconnect outside current test) self::$stomp = $stomp; }