public function testIterator()
 {
     $stream = fopen('php://temp', 'w+b');
     $messages = array('message #1', 'message #2', 'message #3');
     $this->writeDummyMessageSet($stream, $messages);
     rewind($stream);
     $socket = Kafka_Socket::createFromStream($stream);
     $set = new Kafka_MessageSet($socket, 0, 0);
     $idx = 0;
     foreach ($set as $offset => $msg) {
         $this->assertEquals($messages[$idx++], $msg->payload());
     }
     $this->assertEquals(count($messages), $idx);
     // test new offset
     $readBytes = $set->validBytes();
     $this->assertEquals(60, $readBytes);
     $readBytes = $set->sizeInBytes();
     $this->assertEquals(60, $readBytes);
     // no more data
     $set = new Kafka_MessageSet($socket, $readBytes, 0);
     $cnt = 0;
     foreach ($set as $offset => $msg) {
         $cnt++;
     }
     $this->assertEquals(0, $cnt);
     fclose($stream);
 }