| @@ 150-157 (lines=8) @@ | ||
| 147 | * |
|
| 148 | * @return void |
|
| 149 | */ |
|
| 150 | public function testFailedAuthorization(): void |
|
| 151 | { |
|
| 152 | $request = $this->request->withHeader('Authorization', 'this-should-fail'); |
|
| 153 | $this->api->setRequest($request); |
|
| 154 | $response = $this->api->response(); |
|
| 155 | $this->assertInstanceOf(JsonResponse::class, $response); |
|
| 156 | $this->assertEquals(403, $response->getStatusCode()); |
|
| 157 | } |
|
| 158 | ||
| 159 | /** |
|
| 160 | * Test that the show method returns json |
|
| @@ 164-173 (lines=10) @@ | ||
| 161 | * |
|
| 162 | * @return void |
|
| 163 | */ |
|
| 164 | public function testFailedCreate(): void |
|
| 165 | { |
|
| 166 | $request = $this->request |
|
| 167 | ->withMethod('POST') |
|
| 168 | ->withHeader('Authorization', 'Bearer 9575d687c61ce66fc190cd2bed464cef'); |
|
| 169 | $this->api->setRequest($request); |
|
| 170 | $response = $this->api->response(); |
|
| 171 | $this->assertInstanceOf(JsonResponse::class, $response); |
|
| 172 | $this->assertEquals(400, $response->getStatusCode()); |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * Test that the show method returns json |
|
| @@ 219-228 (lines=10) @@ | ||
| 216 | * |
|
| 217 | * @return void |
|
| 218 | */ |
|
| 219 | public function testNotFound(): void |
|
| 220 | { |
|
| 221 | $request = $this->request |
|
| 222 | ->withMethod('GET') |
|
| 223 | ->withUri(new Uri('http://www.example.com/pizza')) |
|
| 224 | ->withHeader('Authorization', 'Bearer 9575d687c61ce66fc190cd2bed464cef'); |
|
| 225 | $this->api->setRequest($request); |
|
| 226 | $response = $this->api->response(); |
|
| 227 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 228 | } |
|
| 229 | ||
| 230 | /** |
|
| 231 | * Test the middleware delegate. |
|