Path: blob/1.0-develop/tests/Traits/Http/IntegrationJsonRequestAssertions.php
7461 views
<?php12namespace Pterodactyl\Tests\Traits\Http;34use Illuminate\Http\Response;5use Illuminate\Testing\TestResponse;67trait IntegrationJsonRequestAssertions8{9/**10* Make assertions about a 404 response on the API.11*/12public function assertNotFoundJson(TestResponse $response): void13{14$response->assertStatus(Response::HTTP_NOT_FOUND);15$response->assertJsonStructure(['errors' => [['code', 'status', 'detail']]]);16$response->assertJsonCount(1, 'errors');17$response->assertJson([18'errors' => [19[20'code' => 'NotFoundHttpException',21'status' => '404',22'detail' => 'The requested resource could not be found on the server.',23],24],25], true);26}2728/**29* Make assertions about a 403 error returned by the API.30*/31public function assertAccessDeniedJson(TestResponse $response): void32{33$response->assertStatus(Response::HTTP_FORBIDDEN);34$response->assertJsonStructure(['errors' => [['code', 'status', 'detail']]]);35$response->assertJsonCount(1, 'errors');36$response->assertJson([37'errors' => [38[39'code' => 'AccessDeniedHttpException',40'status' => '403',41'detail' => 'This action is unauthorized.',42],43],44], true);45}46}474849