15
15
use Symfony \Component \Security \Core \Authentication \Token \AnonymousToken ;
16
16
use Symfony \Component \Security \Core \Exception \CustomUserMessageAuthenticationException ;
17
17
18
+ class ChildCustomUserMessageAuthenticationException extends CustomUserMessageAuthenticationException
19
+ {
20
+ public function serialize ()
21
+ {
22
+ return serialize ([$ this ->childMember , parent ::serialize ()]);
23
+ }
24
+
25
+ public function unserialize ($ str )
26
+ {
27
+ list ($ this ->childMember , $ parentData ) = unserialize ($ str );
28
+
29
+ parent ::unserialize ($ parentData );
30
+ }
31
+ }
32
+
18
33
class CustomUserMessageAuthenticationExceptionTest extends TestCase
19
34
{
20
35
public function testConstructWithSAfeMessage ()
@@ -39,4 +54,18 @@ public function testSharedSerializedData()
39
54
$ this ->assertEquals ($ token , $ processed ->getMessageData ()['token ' ]);
40
55
$ this ->assertSame ($ processed ->getToken (), $ processed ->getMessageData ()['token ' ]);
41
56
}
57
+
58
+ public function testSharedSerializedDataFromChild ()
59
+ {
60
+ $ token = new AnonymousToken ('foo ' , 'bar ' );
61
+
62
+ $ exception = new ChildCustomUserMessageAuthenticationException ();
63
+ $ exception ->childMember = $ token ;
64
+ $ exception ->setToken ($ token );
65
+
66
+ $ processed = unserialize (serialize ($ exception ));
67
+ $ this ->assertEquals ($ token , $ processed ->childMember );
68
+ $ this ->assertEquals ($ token , $ processed ->getToken ());
69
+ $ this ->assertSame ($ processed ->getToken (), $ processed ->childMember );
70
+ }
42
71
}
0 commit comments