public function testByteMessageAutoContentLengthOn() { $frame = new Frame(); $frame->setCommand('TESTING'); $frame->setAutoContentLength(true); $frame->setBody('hello ' . Frame::END_OF_FRAME . ' world'); $connection = new ConnectionSocketOverload(); $connection->setSocket($this->_socket); $connection->write($frame); rewind($this->_socket); $test = $connection->read(); $this->assertEquals('hello ' . Frame::END_OF_FRAME . ' world', $test->getBody()); }
public function test_parameters() { $frame = new Stomp\Frame(); try { $frame->setAutoContentLength(array()); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } try { $frame->setHeader(array(), 1); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } try { $frame->setHeader('testing', array()); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } try { $frame->getHeader(array()); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } try { $frame->setBody(array()); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } try { $frame->setCommand(array()); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } try { $frame->toFrame(); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } try { $frame->fromFrame(array()); $this->fail('Exception should have been thrown'); } catch (\Exception $e) { $this->assertTrue(true); } }
public function testSendAndReceiveByteMessage() { $frame = new Frame(); $frame->setCommand('testing'); $frame->setHeader('testing',1); $frame->setBody('hello ' . Frame::END_OF_FRAME . ' world'); $client = new Client(); $client->addConnection('tcp', 'localhost', '11232', '\ZendTest\Queue\Stomp\Mock'); $client->send($frame); $this->assertTrue($client->canRead()); $test = $client->receive(); $this->assertEquals('testing', $test->getCommand()); $this->assertEquals(1, $test->getHeader('testing')); $this->assertEquals('hello ' . Frame::END_OF_FRAME . ' world', $test->getBody()); }