From a323f1e65da2c512f971a2edf1918a0cca340015 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 27 Jan 2017 13:17:54 -0800 Subject: Oneof accessor should return the field name that is actually set. (#2631) --- php/tests/generated_class_test.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'php/tests/generated_class_test.php') diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index 27912ecd..3587092e 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -573,23 +573,28 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase public function testOneofField() { $m = new TestMessage(); + $this->assertSame("", $m->getMyOneof()); + $m->setOneofInt32(1); $this->assertSame(1, $m->getOneofInt32()); $this->assertSame(0.0, $m->getOneofFloat()); $this->assertSame('', $m->getOneofString()); $this->assertSame(NULL, $m->getOneofMessage()); + $this->assertSame("oneof_int32", $m->getMyOneof()); $m->setOneofFloat(2.0); $this->assertSame(0, $m->getOneofInt32()); $this->assertSame(2.0, $m->getOneofFloat()); $this->assertSame('', $m->getOneofString()); $this->assertSame(NULL, $m->getOneofMessage()); + $this->assertSame("oneof_float", $m->getMyOneof()); $m->setOneofString('abc'); $this->assertSame(0, $m->getOneofInt32()); $this->assertSame(0.0, $m->getOneofFloat()); $this->assertSame('abc', $m->getOneofString()); $this->assertSame(NULL, $m->getOneofMessage()); + $this->assertSame("oneof_string", $m->getMyOneof()); $sub_m = new TestMessage_Sub(); $sub_m->setA(1); @@ -598,6 +603,7 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase $this->assertSame(0.0, $m->getOneofFloat()); $this->assertSame('', $m->getOneofString()); $this->assertSame(1, $m->getOneofMessage()->getA()); + $this->assertSame("oneof_message", $m->getMyOneof()); } ######################################################### -- cgit v1.2.3