@@ -60,6 +60,14 @@ public function testFailToCreateEnumWithInvalidValueThroughNamedConstructor($val
60
60
EnumFixture::from ($ value );
61
61
}
62
62
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
+
63
71
/**
64
72
* Contains values not existing in EnumFixture
65
73
* @return array
@@ -316,12 +324,13 @@ public function testSerialize()
316
324
{
317
325
// split string for Pretty CI: "Line exceeds 120 characters"
318
326
$ bin = '4f3a33303a224d79434c6162735c54657374735c456e756d5c456e756d4669787 ' .
319
- '4757265223a313a7b733a383a22002a0076616c7565223b733a333a22666f6f223b7d ' ;
327
+ '4757265223a323a7b733a383a22002a0076616c7565223b733a333a22666f6f223b73 ' .
328
+ '3a32323a22004d79434c6162735c456e756d5c456e756d006b6579223b733a333a22464f4f223b7d ' ;
320
329
321
330
$ this ->assertEquals ($ bin , bin2hex (serialize (EnumFixture::FOO ())));
322
331
}
323
332
324
- public function testUnserialize ()
333
+ public function testUnserializeVersionWithoutKey ()
325
334
{
326
335
// split string for Pretty CI: "Line exceeds 120 characters"
327
336
$ bin = '4f3a33303a224d79434c6162735c54657374735c456e756d5c456e756d4669787 ' .
@@ -332,6 +341,22 @@ public function testUnserialize()
332
341
333
342
$ this ->assertEquals (EnumFixture::FOO , $ value ->getValue ());
334
343
$ 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 );
335
360
}
336
361
337
362
/**
0 commit comments