public function testSimpleSerializedSize() { $simple = new Simple(); $calculator = $this->getMock(SizeCalculator::CLASS, [], [], '', false); $context = $this->getMock(ComputeSizeContext::CLASS, [], [], '', false); $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); $context->expects($this->once())->method('getSizeCalculator')->willReturn($calculator); $calculator->expects($this->exactly(4))->method('computeVarintSize')->will($this->returnValueMap([[-123456789123456789, 10], [123456789123456789, 9], [-123456789, 10], [123456789, 4]])); $calculator->expects($this->once())->method('computeStringSize')->with('foo')->willReturn(3); $calculator->expects($this->once())->method('computeByteStreamSize')->with('bar')->willReturn(3); $calculator->expects($this->once())->method('computeZigzag32Size')->with(-123456789)->willReturn(4); $calculator->expects($this->once())->method('computeZigzag64Size')->with(-123456789123456789)->willReturn(9); $simple->serializedSize($context); }