15
15
use Symfony \Component \HttpFoundation \Request ;
16
16
use Symfony \Component \HttpFoundation \Response ;
17
17
use Symfony \Component \HttpKernel \Event \ExceptionEvent ;
18
- use Symfony \Component \HttpKernel \Event \GetResponseForExceptionEvent ;
19
18
use Symfony \Component \HttpKernel \Exception \HttpException ;
20
19
use Symfony \Component \HttpKernel \HttpKernelInterface ;
21
20
use Symfony \Component \Security \Core \Authentication \AuthenticationTrustResolverInterface ;
@@ -40,7 +39,7 @@ public function testAuthenticationExceptionWithoutEntryPoint(\Exception $excepti
40
39
$ listener ->onKernelException ($ event );
41
40
42
41
$ this ->assertNull ($ event ->getResponse ());
43
- $ this ->assertEquals ($ eventException , $ event ->getException ());
42
+ $ this ->assertEquals ($ eventException , $ event ->getThrowable ());
44
43
}
45
44
46
45
/**
@@ -59,7 +58,7 @@ public function testAuthenticationExceptionWithEntryPoint(\Exception $exception)
59
58
60
59
$ this ->assertEquals ('Forbidden ' , $ event ->getResponse ()->getContent ());
61
60
$ this ->assertEquals (403 , $ event ->getResponse ()->getStatusCode ());
62
- $ this ->assertSame ($ exception , $ event ->getException ());
61
+ $ this ->assertSame ($ exception , $ event ->getThrowable ());
63
62
}
64
63
65
64
public function getAuthenticationExceptionProvider ()
@@ -86,8 +85,8 @@ public function testExceptionWhenEntryPointReturnsBadValue()
86
85
$ listener = $ this ->createExceptionListener (null , null , null , $ entryPoint );
87
86
$ listener ->onKernelException ($ event );
88
87
// the exception has been replaced by our LogicException
89
- $ this ->assertInstanceOf ('LogicException ' , $ event ->getException ());
90
- $ this ->assertStringEndsWith ('start() method must return a Response object (string returned) ' , $ event ->getException ()->getMessage ());
88
+ $ this ->assertInstanceOf ('LogicException ' , $ event ->getThrowable ());
89
+ $ this ->assertStringEndsWith ('start() method must return a Response object (string returned) ' , $ event ->getThrowable ()->getMessage ());
91
90
}
92
91
93
92
/**
@@ -101,7 +100,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle
101
100
$ listener ->onKernelException ($ event );
102
101
103
102
$ this ->assertNull ($ event ->getResponse ());
104
- $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getException ()->getPrevious ());
103
+ $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getThrowable ()->getPrevious ());
105
104
}
106
105
107
106
/**
@@ -124,7 +123,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle
124
123
125
124
$ this ->assertEquals ('Unauthorized ' , $ event ->getResponse ()->getContent ());
126
125
$ this ->assertEquals (401 , $ event ->getResponse ()->getStatusCode ());
127
- $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getException ()->getPrevious ());
126
+ $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getThrowable ()->getPrevious ());
128
127
}
129
128
130
129
/**
@@ -141,7 +140,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn
141
140
$ listener ->onKernelException ($ event );
142
141
143
142
$ this ->assertEquals ('error ' , $ event ->getResponse ()->getContent ());
144
- $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getException ()->getPrevious ());
143
+ $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getThrowable ()->getPrevious ());
145
144
}
146
145
147
146
/**
@@ -158,7 +157,7 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \
158
157
$ listener ->onKernelException ($ event );
159
158
160
159
$ this ->assertEquals ('OK ' , $ event ->getResponse ()->getContent ());
161
- $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getException ()->getPrevious ());
160
+ $ this ->assertSame (null === $ eventException ? $ exception : $ eventException , $ event ->getThrowable ()->getPrevious ());
162
161
}
163
162
164
163
public function getAccessDeniedExceptionProvider ()
@@ -194,11 +193,7 @@ private function createEvent(\Exception $exception, $kernel = null)
194
193
$ kernel = $ this ->getMockBuilder ('Symfony\Component\HttpKernel\HttpKernelInterface ' )->getMock ();
195
194
}
196
195
197
- if (class_exists (ExceptionEvent::class)) {
198
- return new ExceptionEvent ($ kernel , Request::create ('/ ' ), HttpKernelInterface::MASTER_REQUEST , $ exception );
199
- }
200
-
201
- return new GetResponseForExceptionEvent ($ kernel , Request::create ('/ ' ), HttpKernelInterface::MASTER_REQUEST , $ exception );
196
+ return new ExceptionEvent ($ kernel , Request::create ('/ ' ), HttpKernelInterface::MASTER_REQUEST , $ exception );
202
197
}
203
198
204
199
private function createExceptionListener (TokenStorageInterface $ tokenStorage = null , AuthenticationTrustResolverInterface $ trustResolver = null , HttpUtils $ httpUtils = null , AuthenticationEntryPointInterface $ authenticationEntryPoint = null , $ errorPage = null , AccessDeniedHandlerInterface $ accessDeniedHandler = null )
0 commit comments