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 ());
42
43
}
43
44
44
45
/**
@@ -58,11 +59,11 @@ public function testAuthenticationExceptionWithEntryPoint(\Exception $exception,
58
59
public function getAuthenticationExceptionProvider ()
59
60
{
60
61
return array (
61
- array (new AuthenticationException ()),
62
- array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ()), $ e ),
63
- array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AuthenticationException ())), $ e ),
64
- array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AccessDeniedException ())), $ e ),
65
- array (new AuthenticationException ('random ' , 0 , new \LogicException ())),
62
+ array ($ e = new AuthenticationException (), new HttpException (Response:: HTTP_UNAUTHORIZED , '' , $ e , array (), 0 )),
63
+ array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ()), new HttpException (Response:: HTTP_UNAUTHORIZED , '' , $ e , array (), 0 ) ),
64
+ array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AuthenticationException ())), new HttpException (Response:: HTTP_UNAUTHORIZED , ' embed ' , $ e , array (), 0 ) ),
65
+ array (new \LogicException ('random ' , 0 , $ e = new AuthenticationException ('embed ' , 0 , new AccessDeniedException ())), new HttpException (Response:: HTTP_UNAUTHORIZED , ' embed ' , $ e , array (), 0 ) ),
66
+ array ($ e = new AuthenticationException ('random ' , 0 , new \LogicException ()), new HttpException (Response:: HTTP_UNAUTHORIZED , ' random ' , $ e , array (), 0 )),
66
67
);
67
68
}
68
69
0 commit comments