ProtobufTest\ProtocSerializeMessageTest::testEncodeSimpleMessageComparingTypesWithProtoc PHP Method

testEncodeSimpleMessageComparingTypesWithProtoc() public method

    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}");
    }