summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt')
-rw-r--r--ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt36
1 files changed, 36 insertions, 0 deletions
diff --git a/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt b/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt
new file mode 100644
index 0000000000..de5af5c549
--- /dev/null
+++ b/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt
@@ -0,0 +1,36 @@
+--TEST--
+ReflectionEnumUnitCase::__construct()
+--FILE--
+<?php
+
+enum Foo {
+ case Bar;
+ const Baz = self::Bar;
+}
+
+echo (new ReflectionEnumUnitCase(Foo::class, 'Bar'))->getName() . "\n";
+
+try {
+ new ReflectionEnumUnitCase(Foo::class, 'Baz');
+} catch (\Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ new ReflectionEnumUnitCase(Foo::class, 'Qux');
+} catch (\Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ new ReflectionEnumUnitCase([], 'Foo');
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+--EXPECT--
+Bar
+Constant Foo::Baz is not a case
+Constant Foo::Qux does not exist
+ReflectionEnumUnitCase::__construct(): Argument #1 ($class) must be of type object|string, array given