/** * testEncodeString method * * @return void */ public function testEncodeString() { $packet = new Packet(Packet::TYPE_PUBLISH); $this->assertSame('', $packet->buffer()); $this->callMethod($packet, 'encodeString', array('foo')); $expected = pack('C*', 0x0, 0x3, 0x66, 0x6f, 0x6f); $this->assertEquals($expected, $packet->buffer()); $this->callMethod($packet, 'encodeString', array('ab')); $expected .= pack('C*', 0x0, 0x2, 0x61, 0x62); $this->assertEquals($expected, $packet->buffer()); }