@@ -59,7 +59,7 @@ protected function setUp(): void
5959 public function it_does_nothing_on_non_json_requests (): void
6060 {
6161 $ listener = new JsonApiProblemExceptionListener ($ this ->exceptionTransformer ->reveal (), false );
62- $ this ->request ->getRequestFormat ()->willReturn ('html ' );
62+ $ this ->request ->getPreferredFormat ()->willReturn ('html ' );
6363 $ this ->request ->getContentType ()->willReturn ('text/html ' );
6464 $ listener ->onKernelException ($ this ->event );
6565
@@ -70,7 +70,7 @@ public function it_does_nothing_on_non_json_requests(): void
7070 public function it_runs_on_json_route_formats (): void
7171 {
7272 $ listener = new JsonApiProblemExceptionListener ($ this ->exceptionTransformer ->reveal (), false );
73- $ this ->request ->getRequestFormat ()->willReturn ('json ' );
73+ $ this ->request ->getPreferredFormat ()->willReturn ('json ' );
7474 $ this ->request ->getContentType ()->willReturn (null );
7575 $ listener ->onKernelException ($ this ->event );
7676
@@ -81,18 +81,29 @@ public function it_runs_on_json_route_formats(): void
8181 public function it_runs_on_json_content_types (): void
8282 {
8383 $ listener = new JsonApiProblemExceptionListener ($ this ->exceptionTransformer ->reveal (), false );
84- $ this ->request ->getRequestFormat ()->willReturn ('html ' );
84+ $ this ->request ->getPreferredFormat ()->willReturn ('html ' );
8585 $ this ->request ->getContentType ()->willReturn ('application/json ' );
8686
8787 $ listener ->onKernelException ($ this ->event );
8888 $ this ->assertApiProblemWithResponseBody (500 , $ this ->parseDataForException ());
8989 }
9090
91+ /** @test */
92+ public function it_runs_on_json_accept_header (): void
93+ {
94+ $ listener = new JsonApiProblemExceptionListener ($ this ->exceptionTransformer ->reveal (), false );
95+ $ this ->request ->getPreferredFormat ()->willReturn ('json ' );
96+ $ this ->request ->getContentType ()->willReturn ('html ' );
97+
98+ $ listener ->onKernelException ($ this ->event );
99+ $ this ->assertApiProblemWithResponseBody (500 , $ this ->parseDataForException ());
100+ }
101+
91102 /** @test */
92103 public function it_parses_an_api_problem_response (): void
93104 {
94105 $ listener = new JsonApiProblemExceptionListener ($ this ->exceptionTransformer ->reveal (), false );
95- $ this ->request ->getRequestFormat ()->willReturn ('json ' );
106+ $ this ->request ->getPreferredFormat ()->willReturn ('json ' );
96107 $ this ->request ->getContentType ()->willReturn ('application/json ' );
97108
98109 $ listener ->onKernelException ($ this ->event );
@@ -103,7 +114,7 @@ public function it_parses_an_api_problem_response(): void
103114 public function it_uses_an_exception_transformer (): void
104115 {
105116 $ listener = new JsonApiProblemExceptionListener ($ this ->exceptionTransformer ->reveal (), false );
106- $ this ->request ->getRequestFormat ()->willReturn ('json ' );
117+ $ this ->request ->getPreferredFormat ()->willReturn ('json ' );
107118 $ this ->request ->getContentType ()->willReturn ('application/json ' );
108119
109120 $ apiProblem = $ this ->prophesize (ApiProblemInterface::class);
@@ -120,7 +131,7 @@ public function it_uses_an_exception_transformer(): void
120131 public function it_returns_the_status_code_from_the_api_problem (): void
121132 {
122133 $ listener = new JsonApiProblemExceptionListener ($ this ->exceptionTransformer ->reveal (), false );
123- $ this ->request ->getRequestFormat ()->willReturn ('json ' );
134+ $ this ->request ->getPreferredFormat ()->willReturn ('json ' );
124135 $ this ->request ->getContentType ()->willReturn ('application/json ' );
125136
126137 $ apiProblem = $ this ->prophesize (ApiProblemInterface::class);
@@ -146,7 +157,7 @@ public function it_parses_a_debuggable_api_problem_response(): void
146157 $ this ->exceptionTransformer ->accepts ($ this ->exception )->willReturn (true );
147158 $ this ->exceptionTransformer ->transform ($ this ->exception )->willReturn ($ apiProblem ->reveal ());
148159
149- $ this ->request ->getRequestFormat ()->willReturn ('json ' );
160+ $ this ->request ->getPreferredFormat ()->willReturn ('json ' );
150161 $ this ->request ->getContentType ()->willReturn ('application/json ' );
151162
152163 $ listener ->onKernelException ($ this ->event );
0 commit comments