aboutsummaryrefslogtreecommitdiffhomepage
path: root/php
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2017-04-19 21:20:55 -0700
committerGravatar GitHub <noreply@github.com>2017-04-19 21:20:55 -0700
commitb97cd573e405dd511b09a9fae124427a29741395 (patch)
tree09575aacb020ac0387d27954b4801b07da616a4a /php
parent7be088202bad3a89498db2e9b19afda9f3929430 (diff)
Add test for nested enum for php (#2989)
Diffstat (limited to 'php')
-rw-r--r--php/tests/generated_class_test.php9
-rw-r--r--php/tests/memory_leak_test.php2
-rw-r--r--php/tests/proto/test.proto6
-rw-r--r--php/tests/proto/test_no_namespace.proto5
4 files changed, 22 insertions, 0 deletions
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index 41d63a60..c5dee2d6 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -295,6 +295,12 @@ class GeneratedClassTest extends TestBase
$this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
}
+ public function testNestedEnum()
+ {
+ $m = new TestMessage();
+ $m->setOptionalNestedEnum(\Foo\TestMessage_NestedEnum::ZERO);
+ }
+
#########################################################
# Test float field.
#########################################################
@@ -835,6 +841,9 @@ class GeneratedClassTest extends TestBase
$m = new TestMessage();
$m->setOptionalNoNamespaceMessage(new NoNameSpaceMessage());
$m->getRepeatedNoNamespaceMessage()[] = new NoNameSpaceMessage();
+
+ $n = new NoNamespaceMessage();
+ $n->setB(NoNamespaceMessage_NestedEnum::ZERO);
}
public function testEnumWithoutNamespace()
diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php
index 6b7077f0..ea7a4c96 100644
--- a/php/tests/memory_leak_test.php
+++ b/php/tests/memory_leak_test.php
@@ -4,11 +4,13 @@
require_once('generated/NoNamespaceEnum.php');
require_once('generated/NoNamespaceMessage.php');
+require_once('generated/NoNamespaceMessage_NestedEnum.php');
require_once('generated/PrefixTestPrefix.php');
require_once('generated/Bar/TestInclude.php');
require_once('generated/Foo/TestEnum.php');
require_once('generated/Foo/TestIncludePrefixMessage.php');
require_once('generated/Foo/TestMessage.php');
+require_once('generated/Foo/TestMessage_NestedEnum.php');
require_once('generated/Foo/TestMessage_Sub.php');
require_once('generated/Foo/TestPackedMessage.php');
require_once('generated/Foo/TestPhpDoc.php');
diff --git a/php/tests/proto/test.proto b/php/tests/proto/test.proto
index cc9bf8c8..b6c14866 100644
--- a/php/tests/proto/test.proto
+++ b/php/tests/proto/test.proto
@@ -102,6 +102,12 @@ message TestMessage {
NoNamespaceEnum optional_no_namespace_enum = 92;
repeated NoNamespaceMessage repeated_no_namespace_message = 93;
repeated NoNamespaceEnum repeated_no_namespace_enum = 94;
+
+ enum NestedEnum {
+ ZERO = 0;
+ }
+
+ NestedEnum optional_nested_enum = 101;
}
enum TestEnum {
diff --git a/php/tests/proto/test_no_namespace.proto b/php/tests/proto/test_no_namespace.proto
index b0f66002..3dd76764 100644
--- a/php/tests/proto/test_no_namespace.proto
+++ b/php/tests/proto/test_no_namespace.proto
@@ -2,6 +2,11 @@ syntax = "proto3";
message NoNamespaceMessage {
int32 a = 1;
+
+ enum NestedEnum {
+ ZERO = 0;
+ }
+ NestedEnum b = 2;
}
enum NoNamespaceEnum {