1515use Symfony \Component \Security \Core \Authentication \Token \AnonymousToken ;
1616use Symfony \Component \Security \Core \Exception \CustomUserMessageAuthenticationException ;
1717
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+
1833class CustomUserMessageAuthenticationExceptionTest extends TestCase
1934{
2035 public function testConstructWithSAfeMessage ()
@@ -39,4 +54,18 @@ public function testSharedSerializedData()
3954 $ this ->assertEquals ($ token , $ processed ->getMessageData ()['token ' ]);
4055 $ this ->assertSame ($ processed ->getToken (), $ processed ->getMessageData ()['token ' ]);
4156 }
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+ }
4271}
0 commit comments