@@ -60,6 +60,14 @@ public function testFailToCreateEnumWithInvalidValueThroughNamedConstructor($val
6060 EnumFixture::from ($ value );
6161 }
6262
63+ public function testFailToCreateEnumWithEnumItselfThroughNamedConstructor (): void
64+ {
65+ $ this ->expectException (\UnexpectedValueException::class);
66+ $ this ->expectExceptionMessage ("Value 'foo' is not part of the enum " . EnumFixture::class);
67+
68+ EnumFixture::from (EnumFixture::FOO ());
69+ }
70+
6371 /**
6472 * Contains values not existing in EnumFixture
6573 * @return array
@@ -316,12 +324,13 @@ public function testSerialize()
316324 {
317325 // split string for Pretty CI: "Line exceeds 120 characters"
318326 $ bin = '4f3a33303a224d79434c6162735c54657374735c456e756d5c456e756d4669787 ' .
319- '4757265223a313a7b733a383a22002a0076616c7565223b733a333a22666f6f223b7d ' ;
327+ '4757265223a323a7b733a383a22002a0076616c7565223b733a333a22666f6f223b73 ' .
328+ '3a32323a22004d79434c6162735c456e756d5c456e756d006b6579223b733a333a22464f4f223b7d ' ;
320329
321330 $ this ->assertEquals ($ bin , bin2hex (serialize (EnumFixture::FOO ())));
322331 }
323332
324- public function testUnserialize ()
333+ public function testUnserializeVersionWithoutKey ()
325334 {
326335 // split string for Pretty CI: "Line exceeds 120 characters"
327336 $ bin = '4f3a33303a224d79434c6162735c54657374735c456e756d5c456e756d4669787 ' .
@@ -332,6 +341,22 @@ public function testUnserialize()
332341
333342 $ this ->assertEquals (EnumFixture::FOO , $ value ->getValue ());
334343 $ this ->assertTrue (EnumFixture::FOO ()->equals ($ value ));
344+ $ this ->assertTrue (EnumFixture::FOO () == $ value );
345+ }
346+
347+ public function testUnserialize ()
348+ {
349+ // split string for Pretty CI: "Line exceeds 120 characters"
350+ $ bin = '4f3a33303a224d79434c6162735c54657374735c456e756d5c456e756d4669787 ' .
351+ '4757265223a323a7b733a383a22002a0076616c7565223b733a333a22666f6f223b73 ' .
352+ '3a32323a22004d79434c6162735c456e756d5c456e756d006b6579223b733a333a22464f4f223b7d ' ;
353+
354+ /* @var $value EnumFixture */
355+ $ value = unserialize (pack ('H* ' , $ bin ));
356+
357+ $ this ->assertEquals (EnumFixture::FOO , $ value ->getValue ());
358+ $ this ->assertTrue (EnumFixture::FOO ()->equals ($ value ));
359+ $ this ->assertTrue (EnumFixture::FOO () == $ value );
335360 }
336361
337362 /**
0 commit comments