From c344fe8caa6da817d3f0ece0babf1d1acbf2bbbf Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 29 May 2017 22:04:20 -0700 Subject: Oneof field should be serialized even it's equal to default. (#3153) --- php/tests/encode_decode_test.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'php/tests/encode_decode_test.php') diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index 288df569..b4cfed42 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -88,6 +88,13 @@ class EncodeDecodeTest extends TestBase $n = new TestMessage(); $n->mergeFromString($data); $this->assertSame(1, $n->getOneofMessage()->getA()); + + // Encode default value + $m->setOneofEnum(TestEnum::ZERO); + $data = $m->serializeToString(); + $n = new TestMessage(); + $n->mergeFromString($data); + $this->assertSame("oneof_enum", $n->getMyOneof()); } public function testPackedEncode() -- cgit v1.2.3