function testSerializeMessageWithRepeatedFields()
 {
     $repeated = new Tests\Repeated();
     $repeated->addString('one');
     $repeated->addString('two');
     $repeated->addString('three');
     $bin = Protobuf::encode($repeated);
     $this->assertEquals($bin, '{"1":["one","two","three"]}');
     $repeated = new Tests\Repeated();
     $repeated->addInt(1);
     $repeated->addInt(2);
     $repeated->addInt(3);
     $bin = Protobuf::encode($repeated);
     $this->assertEquals($bin, '{"2":[1,2,3]}');
     $repeated = new Tests\Repeated();
     $nested = new Tests\Repeated\Nested();
     $nested->setId(1);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(2);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(3);
     $repeated->addNested($nested);
     $json = Protobuf::encode($repeated);
     $this->assertEquals($json, '{"3":[{"1":1},{"1":2},{"1":3}]}');
 }
 function testSerializeMessageWithRepeatedFields()
 {
     $repeated = new \Tests\Repeated();
     $repeated->addString('one');
     $repeated->addString('two');
     $repeated->addString('three');
     $txt = Protobuf::encode($repeated);
     $this->assertEquals($txt, "string: \"one\"\nstring: \"two\"\nstring: \"three\"\n");
     $repeated = new Tests\Repeated();
     $repeated->addInt(1);
     $repeated->addInt(2);
     $repeated->addInt(3);
     $txt = Protobuf::encode($repeated);
     $this->assertEquals($txt, "int: 1\nint: 2\nint: 3\n");
     $repeated = new Tests\Repeated();
     $nested = new Tests\Repeated\Nested();
     $nested->setId(1);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(2);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(3);
     $repeated->addNested($nested);
     $txt = Protobuf::encode($repeated);
     $this->assertEquals($txt, "nested {\n  id: 1\n}\nnested {\n  id: 2\n}\nnested {\n  id: 3\n}\n");
 }
 function testSerializeMessageWithRepeatedFields()
 {
     $repeated = new Tests\Repeated();
     $repeated->addString('one');
     $repeated->addString('two');
     $repeated->addString('three');
     $bin = Protobuf::encode($repeated);
     $this->assertEquals($bin, '["1",["one","two","three"]]');
     $repeated = new Tests\Repeated();
     $repeated->addInt(1);
     $repeated->addInt(2);
     $repeated->addInt(3);
     $bin = Protobuf::encode($repeated);
     $this->assertEquals($bin, '["2",[1,2,3]]');
     $repeated = new Tests\Repeated();
     $nested = new Tests\Repeated\Nested();
     $nested->setId(1);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(2);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(3);
     $repeated->addNested($nested);
     $json = Protobuf::encode($repeated);
     $this->assertEquals($json, '["3",[["1",1],["1",2],["1",3]]]');
 }
 function testSerializeMessageWithRepeatedFields()
 {
     $repeated = new \Tests\Repeated();
     $repeated->addString('one');
     $repeated->addString('two');
     $repeated->addString('three');
     $xml = Protobuf::encode($repeated);
     $xml = simplexml_load_string($xml);
     $this->assertEquals((string) $xml->string[0], 'one');
     $this->assertEquals((string) $xml->string[1], 'two');
     $this->assertEquals((string) $xml->string[2], 'three');
     $repeated = new Tests\Repeated();
     $repeated->addInt(1);
     $repeated->addInt(2);
     $repeated->addInt(3);
     $xml = Protobuf::encode($repeated);
     $xml = simplexml_load_string($xml);
     $this->assertEquals((string) $xml->int[0], 1);
     $this->assertEquals((string) $xml->int[1], 2);
     $this->assertEquals((string) $xml->int[2], 3);
     $repeated = new Tests\Repeated();
     $nested = new Tests\Repeated\Nested();
     $nested->setId(1);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(2);
     $repeated->addNested($nested);
     $nested = new Tests\Repeated\Nested();
     $nested->setId(3);
     $repeated->addNested($nested);
     $xml = Protobuf::encode($repeated);
     $xml = simplexml_load_string($xml);
     $this->assertEquals((int) $xml->nested[0]->id, 1);
     $this->assertEquals((int) $xml->nested[1]->id, 2);
     $this->assertEquals((int) $xml->nested[2]->id, 3);
 }