Add test for nested enum for php (#2989)

pull/2990/head
Paul Yang 8 years ago committed by GitHub
parent 7be088202b
commit b97cd573e4
  1. 9
      php/tests/generated_class_test.php
  2. 2
      php/tests/memory_leak_test.php
  3. 6
      php/tests/proto/test.proto
  4. 5
      php/tests/proto/test_no_namespace.proto

@ -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()

@ -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');

@ -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 {

@ -2,6 +2,11 @@ syntax = "proto3";
message NoNamespaceMessage {
int32 a = 1;
enum NestedEnum {
ZERO = 0;
}
NestedEnum b = 2;
}
enum NoNamespaceEnum {

Loading…
Cancel
Save