public function testWriteSimpleMessageTwice()
 {
     $simple = new Simple();
     $simple->setBool(true);
     $simple->setBytes("bar");
     $simple->setString("foo");
     $simple->setFloat(12345.123);
     $simple->setUint32(123456789);
     $simple->setInt32(-123456789);
     $simple->setFixed32(123456789);
     $simple->setSint32(-123456789);
     $simple->setSfixed32(-123456789);
     $simple->setDouble(123456789.12345);
     $simple->setInt64(-123456789123456789);
     $simple->setUint64(123456789123456789);
     $simple->setFixed64(123456789123456789);
     $simple->setSint64(-123456789123456789);
     $simple->setSfixed64(-123456789123456789);
     $expected = $this->getProtoContent('simple.bin');
     $actual1 = $simple->toStream();
     $actual2 = $simple->toStream();
     $this->assertEquals($expected, (string) $actual1);
     $this->assertEquals($expected, (string) $actual2);
 }
 /**
  * @dataProvider simpleMessageProvider
  */
 public function testEncodeSimpleMessageComparingTypesWithProtoc($field, $value)
 {
     $escaped = $value;
     $proto = 'simple';
     $message = new Simple();
     $setter = 'set' . ucfirst($field);
     $class = 'ProtobufTest.Protos.Simple';
     if (is_string($value)) {
         $escaped = '"' . $value . '"';
     }
     if ($value instanceof \Protobuf\Stream) {
         $tell = $value->tell();
         $escaped = '"' . $value . '"';
         $value->seek($tell);
     }
     $message->{$setter}($value);
     $encoded = $message->toStream();
     $expected = $this->executeProtoc("{$field}: {$escaped}", $class, $proto);
     $this->assertEquals(bin2hex($expected), bin2hex($encoded), "Encoding {$field} with value {$value}");
 }