function it_generates_a_packet_with_correct_offset(Chunk $chunk)
 {
     $this->beConstructedWith(8);
     $chunk->getField()->willReturn('otherfield');
     $chunk->getValue()->willReturn('more and more data');
     $packet = new Packet(19, 10, 18, 8);
     $this->fromChunk($chunk, 19)->shouldBeLike($packet);
 }
 function it_generates_a_payload(Chunk $firstChunk, Chunk $secondChunk, Packet $firstPacket, Packet $secondPacket, PacketGenerator $generator)
 {
     $chunkFactory = new ChunkFactory();
     $firstChunk->__toString()->willReturn('field some data');
     $secondChunk->__toString()->willReturn('otherfield more and more data');
     $generator->fromChunk($firstChunk)->willReturn($firstPacket);
     $generator->fromChunk($secondChunk)->willReturn($secondPacket);
     $firstPacket->__toString()->willReturn('0013');
     $secondPacket->__toString()->willReturn('0021');
     $this->beConstructedWith($chunkFactory, $generator);
     $payload = new Payload($chunkFactory, '0013field some data0021otherfield more and more data');
     $this->generate(array($firstChunk, $secondChunk))->shouldBeLike($payload);
 }
 public function fromChunk(Chunk $chunk, $start = 0)
 {
     $fieldLength = strlen($chunk->getField());
     $valueLength = strlen($chunk->getValue());
     return new DataPacket($start, $fieldLength, $valueLength, $this->getBufferSize());
 }