15
15
use Symfony \Component \HttpFoundation \Request ;
16
16
use Symfony \Component \HttpFoundation \Response ;
17
17
use Symfony \Component \HttpKernel \Event \GetResponseForExceptionEvent ;
18
+ use Symfony \Component \HttpKernel \Exception \HttpException ;
18
19
use Symfony \Component \HttpKernel \HttpKernelInterface ;
19
20
use Symfony \Component \Security \Core \Authentication \AuthenticationTrustResolverInterface ;
20
21
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
@@ -30,15 +31,15 @@ class ExceptionListenerTest extends TestCase
30
31
/**
31
32
* @dataProvider getAuthenticationExceptionProvider
32
33
*/
33
- public function testAuthenticationExceptionWithoutEntryPoint (\Exception $ exception , \Exception $ eventException = null )
34
+ public function testAuthenticationExceptionWithoutEntryPoint (\Exception $ exception , \Exception $ eventException )
34
35
{
35
36
$ event = $ this ->createEvent ($ exception );
36
37
37
38
$ listener = $ this ->createExceptionListener ();
38
39
$ listener ->onKernelException ($ event );
39
40
40
41
$ this ->assertNull ($ event ->getResponse ());
41
- $ this ->assertSame ( null === $ eventException ? $ exception : $ eventException, $ event ->getException ());
42
+ $ this ->assertEquals ( $ eventException, $ event -> getException (), ' Objects are not the same: expected " ' . get_class ( $ eventException). ' ", got " ' . get_class ( $ event ->getException ()). ' ". ' );
42
43
}
43
44
44
45
/**
@@ -63,11 +64,11 @@ public function testAuthenticationExceptionWithEntryPoint(\Exception $exception)
63
64
public function getAuthenticationExceptionProvider ()
64
65
{
65
66
return array (
66
- array (new AuthenticationException ()),
67
- array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ()), $ e ),
68
- array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AuthenticationException ())), $ e ),
69
- array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AccessDeniedException ())), $ e ),
70
- array (new AuthenticationException ('random ' , 0 , new \LogicException ())),
67
+ array ($ e = new AuthenticationException (), new HttpException ( 401 , '' , $ e , array (), 0 )),
68
+ array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ()), new HttpException ( 401 , '' , $ e , array (), 0 ) ),
69
+ array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AuthenticationException ())), new HttpException ( 401 , ' embed ' , $ e , array (), 0 ) ),
70
+ array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AccessDeniedException ())), new HttpException ( 401 , ' embed ' , $ e , array (), 0 ) ),
71
+ array ($ e = new AuthenticationException ('random ' , 0 , new \LogicException ()), new HttpException ( 401 , ' random ' , $ e , array (), 0 )),
71
72
);
72
73
}
73
74
0 commit comments