File tree 3 files changed +26
-3
lines changed
3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,7 @@ abstract class Enum implements \JsonSerializable
41
41
public function __construct ($ value )
42
42
{
43
43
if ($ value instanceof static) {
44
- $ this ->value = $ value ->getValue ();
45
-
46
- return ;
44
+ $ value = $ value ->getValue ();
47
45
}
48
46
49
47
if (!$ this ->isValid ($ value )) {
Original file line number Diff line number Diff line change @@ -320,4 +320,15 @@ public function testUnserialize()
320
320
$ this ->assertEquals (EnumFixture::FOO , $ value ->getValue ());
321
321
$ this ->assertTrue (EnumFixture::FOO ()->equals ($ value ));
322
322
}
323
+
324
+ /**
325
+ * @see https://github.com/myclabs/php-enum/issues/95
326
+ */
327
+ public function testEnumValuesInheritance ()
328
+ {
329
+ $ this ->expectException (\UnexpectedValueException::class);
330
+ $ this ->expectExceptionMessage ("Value 'value' is not part of the enum MyCLabs\Tests\Enum\EnumFixture " );
331
+ $ inheritedEnumFixture = InheritedEnumFixture::VALUE ();
332
+ new EnumFixture ($ inheritedEnumFixture );
333
+ }
323
334
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \Tests \Enum ;
4
+
5
+ /**
6
+ * Class InheritedEnumFixture.
7
+ * @package MyCLabs\Tests\Enum
8
+ *
9
+ * @method static InheritedEnumFixture VALUE()
10
+ */
11
+ class InheritedEnumFixture extends EnumFixture
12
+ {
13
+ const VALUE = 'value ' ;
14
+ }
You can’t perform that action at this time.
0 commit comments