diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2016-10-11 10:36:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 10:36:25 -0700 |
commit | 60d95f36c0081a03b947c2b625c10841bb19736c (patch) | |
tree | 18a505eb1da4f6072afb9344af72880f0d789d3a /php/tests | |
parent | 0321baf9e855a2b664436605c7067f348e1d7284 (diff) | |
download | protobuf-60d95f36c0081a03b947c2b625c10841bb19736c.tar.gz protobuf-60d95f36c0081a03b947c2b625c10841bb19736c.tar.bz2 protobuf-60d95f36c0081a03b947c2b625c10841bb19736c.zip |
Fix the bug that message without namespace is not found in the descriptor pool. (#2240)
Diffstat (limited to 'php/tests')
-rw-r--r-- | php/tests/generated_class_test.php | 9 | ||||
-rw-r--r-- | php/tests/test_no_namespace.pb.php | 34 | ||||
-rw-r--r-- | php/tests/test_no_namespace.proto | 5 |
3 files changed, 48 insertions, 0 deletions
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index 56466cae..d1a0bd51 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -1,6 +1,7 @@ <?php require_once('test.pb.php'); +require_once('test_no_namespace.pb.php'); require_once('test_util.php'); use Google\Protobuf\Internal\RepeatedField; @@ -554,4 +555,12 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase $this->assertSame('', $m->getOneofString()); $this->assertSame(1, $m->getOneofMessage()->getA()); } + + ######################################################### + # Test oneof field. + ######################################################### + + public function testMessageWithoutNamespace() { + $m = new NoNameSpace(); + } } diff --git a/php/tests/test_no_namespace.pb.php b/php/tests/test_no_namespace.pb.php new file mode 100644 index 00000000..2f92c955 --- /dev/null +++ b/php/tests/test_no_namespace.pb.php @@ -0,0 +1,34 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: test_no_namespace.proto + +use Google\Protobuf\Internal\DescriptorPool; +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\GPBUtil; + +class NoNameSpace extends \Google\Protobuf\Internal\Message +{ + private $a = 0; + + public function getA() + { + return $this->a; + } + + public function setA($var) + { + GPBUtil::checkInt32($var); + $this->a = $var; + } + +} + +$pool = DescriptorPool::getGeneratedPool(); + +$pool->internalAddGeneratedFile(hex2bin( + "0a3b0a17746573745f6e6f5f6e616d6573706163652e70726f746f22180a" . + "0b4e6f4e616d65537061636512090a0161180120012805620670726f746f" . + "33" +)); + diff --git a/php/tests/test_no_namespace.proto b/php/tests/test_no_namespace.proto new file mode 100644 index 00000000..4331aeab --- /dev/null +++ b/php/tests/test_no_namespace.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +message NoNameSpace { + int32 a = 1; +} |