public function testAddressBookWithExtensionsSerializedSize() { $message = new AddressBook(); $person = $this->getMock(Person::CLASS); $calculator = $this->getMock(SizeCalculator::CLASS, [], [], '', false); $extensions = $this->getMock(ExtensionFieldMap::CLASS, [], [], '', false); $context = $this->getMock(ComputeSizeContext::CLASS, [], [], '', false); $personSize = 2; $extSize = 4; $message->addPerson($person); $this->setPropertyValue($message, 'extensions', $extensions); $context->expects($this->once())->method('getSizeCalculator')->willReturn($calculator); $calculator->expects($this->once())->method('computeVarintSize')->with($this->equalTo($personSize))->willReturn(1); $extensions->expects($this->once())->method('serializedSize')->willReturn($extSize)->with($context); $person->expects($this->once())->method('serializedSize')->willReturn($personSize)->with($context); $message->serializedSize($context); }