aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/tests
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2017-01-27 13:17:54 -0800
committerGravatar GitHub <noreply@github.com>2017-01-27 13:17:54 -0800
commita323f1e65da2c512f971a2edf1918a0cca340015 (patch)
tree22ae538979fd53567f144a112b069ae2706a03e0 /php/tests
parent5af0b547de7aba6d6206943546262cb21fedc721 (diff)
Oneof accessor should return the field name that is actually set. (#2631)
Diffstat (limited to 'php/tests')
-rw-r--r--php/tests/generated_class_test.php6
1 files changed, 6 insertions, 0 deletions
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());
}
#########################################################