Added proto3 presence support for PHP (#7724)
* WIP.
* Added proto3 presence support for PHP.
* Added compatibility code for old generated code.
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index 053697d..f49c4e9 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -72,6 +72,28 @@
}
#########################################################
+ # Test optional int32 field.
+ #########################################################
+
+ public function testOptionalInt32Field()
+ {
+ $m = new TestMessage();
+
+ $this->assertFalse($m->hasTrueOptionalInt32());
+ $this->assertSame(0, $m->getTrueOptionalInt32());
+
+ // Set integer.
+ $m->setTrueOptionalInt32(MAX_INT32);
+ $this->assertTrue($m->hasTrueOptionalInt32());
+ $this->assertSame(MAX_INT32, $m->getTrueOptionalInt32());
+
+ // Clear integer.
+ $m->clearTrueOptionalInt32();
+ $this->assertFalse($m->hasTrueOptionalInt32());
+ $this->assertSame(0, $m->getTrueOptionalInt32());
+ }
+
+ #########################################################
# Test uint32 field.
#########################################################