1
1
<?php
2
2
/*
3
- * Copyright 2022 Cloud Creativity Limited
3
+ * Copyright 2023 Cloud Creativity Limited
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
6
* you may not use this file except in compliance with the License.
19
19
20
20
namespace LaravelJsonApi \Exceptions \Tests \Integration ;
21
21
22
- use Carbon \Carbon ;
23
22
use Illuminate \Auth \Access \AuthorizationException ;
24
23
use Illuminate \Auth \AuthenticationException ;
25
24
use Illuminate \Contracts \Translation \Translator ;
26
- use Illuminate \Foundation \Http \Exceptions \MaintenanceModeException ;
27
25
use Illuminate \Session \TokenMismatchException ;
28
26
use Illuminate \Support \Arr ;
29
27
use Illuminate \Support \Collection ;
@@ -62,8 +60,7 @@ public function testNotFound(): void
62
60
$ expected = [
63
61
'errors ' => [
64
62
[
65
- // @TODO added in Laravel 9
66
- // 'detail' => 'The route foobar could not be found.',
63
+ 'detail ' => 'The route foobar could not be found. ' ,
67
64
'status ' => '404 ' ,
68
65
'title ' => 'Not Found ' ,
69
66
],
@@ -76,16 +73,15 @@ public function testNotFound(): void
76
73
$ this ->get ('/foobar ' , ['Accept ' => 'application/vnd.api+json ' ])
77
74
->assertStatus (404 )
78
75
->assertHeader ('Content-Type ' , 'application/vnd.api+json ' )
79
- ->assertJson ($ expected ); // @TODO revert to `assertExactJson` when using only Laravel 9
76
+ ->assertExactJson ($ expected );
80
77
}
81
78
82
79
public function testMethodNotAllowed (): void
83
80
{
84
81
$ expected = [
85
82
'errors ' => [
86
83
[
87
- // @TODO detail has changed in Laravel 9
88
- // 'detail' => 'The POST method is not supported for this route. Supported methods: GET, HEAD.',
84
+ 'detail ' => 'The POST method is not supported for route test. Supported methods: GET, HEAD. ' ,
89
85
'status ' => '405 ' ,
90
86
'title ' => 'Method Not Allowed ' ,
91
87
],
@@ -98,7 +94,7 @@ public function testMethodNotAllowed(): void
98
94
$ this ->post ('/test ' , [], ['Accept ' => 'application/vnd.api+json ' ])
99
95
->assertStatus (405 )
100
96
->assertHeader ('Content-Type ' , 'application/vnd.api+json ' )
101
- ->assertJson ($ expected ); // @TODO revert back to `assertExactJson`
97
+ ->assertExactJson ($ expected );
102
98
}
103
99
104
100
/**
@@ -158,34 +154,12 @@ public function testJsonApiException(): void
158
154
159
155
public function testMaintenanceMode (): void
160
156
{
161
- $ this ->ex = new MaintenanceModeException (Carbon::now ()->getTimestamp (), 60 , "We'll be back soon. " );
162
-
163
- $ expected = [
164
- 'errors ' => [
165
- [
166
- 'title ' => 'Service Unavailable ' ,
167
- 'detail ' => "We'll be back soon. " ,
168
- 'status ' => '503 ' ,
169
- ],
170
- ],
171
- 'jsonapi ' => [
172
- 'version ' => '1.0 ' ,
173
- ],
174
- ];
175
-
176
- $ this ->get ('/test ' , ['Accept ' => 'application/vnd.api+json ' ])
177
- ->assertStatus (503 )
178
- ->assertHeader ('Content-Type ' , 'application/vnd.api+json ' )
179
- ->assertExactJson ($ expected );
180
- }
181
-
182
- public function testMaintenanceModeWithoutMessage (): void
183
- {
184
- $ this ->ex = new MaintenanceModeException (Carbon::now ()->getTimestamp (), 60 , '' );
157
+ $ this ->ex = new HttpException (503 , 'We are down for maintenance. ' );
185
158
186
159
$ expected = [
187
160
'errors ' => [
188
161
[
162
+ 'detail ' => 'We are down for maintenance. ' ,
189
163
'title ' => 'Service Unavailable ' ,
190
164
'status ' => '503 ' ,
191
165
],
0 commit comments