ProtobufTest\SerializeMessageTest::testWriteComplexMessage PHP Method

testWriteComplexMessage() public method

    public function testWriteComplexMessage()
    {
        $phone1 = new PhoneNumber();
        $phone2 = new PhoneNumber();
        $phone3 = new PhoneNumber();
        $book = new AddressBook();
        $person1 = new Person();
        $person2 = new Person();
        $person1->setId(2051);
        $person1->setName('John Doe');
        $person1->setEmail('[email protected]');
        $person2->setId(23);
        $person2->setName('Iván Montes');
        $person2->setEmail('[email protected]');
        $book->addPerson($person1);
        $book->addPerson($person2);
        $person1->addPhone($phone1);
        $person1->addPhone($phone2);
        $phone1->setNumber('1231231212');
        $phone1->setType(PhoneType::HOME());
        $phone2->setNumber('55512321312');
        $phone2->setType(PhoneType::MOBILE());
        $phone3->setNumber('3493123123');
        $phone3->setType(PhoneType::WORK());
        $person2->addPhone($phone3);
        $expected = $this->getProtoContent('addressbook.bin');
        $actual = $book->toStream();
        $this->assertEquals($expected, (string) $actual);
        $this->assertSerializedMessageSize($expected, $book);
    }