summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt')
-rw-r--r--ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt38
1 files changed, 38 insertions, 0 deletions
diff --git a/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt b/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt
new file mode 100644
index 0000000000..f81241d73a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt
@@ -0,0 +1,38 @@
+--TEST--
+ReflectionEnumBackedCase::getBackingValue()
+--FILE--
+<?php
+
+enum Enum_ {
+ case Foo;
+}
+
+enum IntEnum: int {
+ case Foo = 0;
+}
+
+enum StringEnum: string {
+ case Foo = 'Foo';
+}
+
+try {
+ var_dump(new ReflectionEnumBackedCase(Enum_::class, 'Foo'));
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ var_dump(new ReflectionEnumBackedCase([], 'Foo'));
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+var_dump((new ReflectionEnumBackedCase(IntEnum::class, 'Foo'))->getBackingValue());
+var_dump((new ReflectionEnumBackedCase(StringEnum::class, 'Foo'))->getBackingValue());
+
+?>
+--EXPECT--
+Enum case Enum_::Foo is not a backed case
+ReflectionEnumBackedCase::__construct(): Argument #1 ($class) must be of type object|string, array given
+int(0)
+string(3) "Foo"