diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2017-04-19 20:03:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 20:03:34 -0700 |
commit | 7be088202bad3a89498db2e9b19afda9f3929430 (patch) | |
tree | b3c027b951251e4e80d173acf0655a3c333ceb24 /php | |
parent | 190b5270c8717ca343db42da489e5e7d6d9efb2c (diff) | |
download | protobuf-7be088202bad3a89498db2e9b19afda9f3929430.tar.gz protobuf-7be088202bad3a89498db2e9b19afda9f3929430.tar.bz2 protobuf-7be088202bad3a89498db2e9b19afda9f3929430.zip |
Enum defined without package have incorrect class name. (#2988)
Fix the bug by sharing the code for generating class name for both
message and enum.
Diffstat (limited to 'php')
-rw-r--r-- | php/tests/generated_class_test.php | 12 | ||||
-rw-r--r-- | php/tests/memory_leak_test.php | 3 | ||||
-rw-r--r-- | php/tests/proto/test.proto | 6 | ||||
-rw-r--r-- | php/tests/proto/test_no_namespace.proto | 4 |
4 files changed, 19 insertions, 6 deletions
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index 39e6c6c4..41d63a60 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -1,7 +1,7 @@ <?php -require_once('generated/NoNameSpaceEnum.php'); -require_once('generated/NoNameSpaceMessage.php'); +require_once('generated/NoNamespaceEnum.php'); +require_once('generated/NoNamespaceMessage.php'); require_once('test_base.php'); require_once('test_util.php'); @@ -832,12 +832,16 @@ class GeneratedClassTest extends TestBase public function testMessageWithoutNamespace() { - $m = new NoNameSpaceMessage(); + $m = new TestMessage(); + $m->setOptionalNoNamespaceMessage(new NoNameSpaceMessage()); + $m->getRepeatedNoNamespaceMessage()[] = new NoNameSpaceMessage(); } public function testEnumWithoutNamespace() { - $m = new NoNameSpaceEnum(); + $m = new TestMessage(); + $m->setOptionalNoNamespaceEnum(NoNameSpaceEnum::VALUE_A); + $m->getRepeatedNoNamespaceEnum()[] = NoNameSpaceEnum::VALUE_A; } ######################################################### diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php index 68b6f5be..6b7077f0 100644 --- a/php/tests/memory_leak_test.php +++ b/php/tests/memory_leak_test.php @@ -2,6 +2,8 @@ # phpunit has memory leak by itself. Thus, it cannot be used to test memory leak. +require_once('generated/NoNamespaceEnum.php'); +require_once('generated/NoNamespaceMessage.php'); require_once('generated/PrefixTestPrefix.php'); require_once('generated/Bar/TestInclude.php'); require_once('generated/Foo/TestEnum.php'); @@ -13,6 +15,7 @@ require_once('generated/Foo/TestPhpDoc.php'); require_once('generated/Foo/TestUnpackedMessage.php'); require_once('generated/GPBMetadata/Proto/Test.php'); require_once('generated/GPBMetadata/Proto/TestInclude.php'); +require_once('generated/GPBMetadata/Proto/TestNoNamespace.php'); require_once('generated/GPBMetadata/Proto/TestPrefix.php'); require_once('test_util.php'); diff --git a/php/tests/proto/test.proto b/php/tests/proto/test.proto index 1a47a3f2..cc9bf8c8 100644 --- a/php/tests/proto/test.proto +++ b/php/tests/proto/test.proto @@ -1,6 +1,7 @@ syntax = "proto3"; import 'proto/test_include.proto'; +import 'proto/test_no_namespace.proto'; import 'proto/test_prefix.proto'; package foo; @@ -96,6 +97,11 @@ message TestMessage { // Reserved for non-existing field test. // int32 non_exist = 89; + + NoNamespaceMessage optional_no_namespace_message = 91; + NoNamespaceEnum optional_no_namespace_enum = 92; + repeated NoNamespaceMessage repeated_no_namespace_message = 93; + repeated NoNamespaceEnum repeated_no_namespace_enum = 94; } enum TestEnum { diff --git a/php/tests/proto/test_no_namespace.proto b/php/tests/proto/test_no_namespace.proto index b8c4fdf2..b0f66002 100644 --- a/php/tests/proto/test_no_namespace.proto +++ b/php/tests/proto/test_no_namespace.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -message NoNameSpaceMessage { +message NoNamespaceMessage { int32 a = 1; } -enum NoNameSpaceEnum { +enum NoNamespaceEnum { VALUE_A = 0; VALUE_B = 1; } |