diff --git a/src/System/Integrate/Testing/Traits/ResponseStatusTrait.php b/src/System/Integrate/Testing/Traits/ResponseStatusTrait.php index 1ebd4de2..b0c129d2 100644 --- a/src/System/Integrate/Testing/Traits/ResponseStatusTrait.php +++ b/src/System/Integrate/Testing/Traits/ResponseStatusTrait.php @@ -13,11 +13,31 @@ public function assertOk(): void $this->assertStatusCode(Response::HTTP_OK, 'Respone code must return ok'); } + public function assertCreated(): void + { + $this->assertStatusCode(Response::HTTP_CREATED, 'Respone code must return create'); + } + public function assertNoContent(): void { $this->assertStatusCode(Response::HTTP_NO_CONTENT, 'Respone code must return no content'); } + public function assertBadRequest(): void + { + $this->assertStatusCode(Response::HTTP_BAD_REQUEST, 'Respone code must return Bad Request'); + } + + public function assertUnauthorized(): void + { + $this->assertStatusCode(Response::HTTP_UNAUTHORIZED, 'Respone code must return Unauthorized'); + } + + public function assertForbidden(): void + { + $this->assertStatusCode(Response::HTTP_FORBIDDEN, 'Respone code must return Forbidden'); + } + public function assertNotFound(): void { $this->assertStatusCode(Response::HTTP_NOT_FOUND, 'Respone code must return Not Found'); diff --git a/tests/Integrate/Testing/Traits/ResponseStatusTest.php b/tests/Integrate/Testing/Traits/ResponseStatusTest.php index 2eebc433..71da3f1e 100644 --- a/tests/Integrate/Testing/Traits/ResponseStatusTest.php +++ b/tests/Integrate/Testing/Traits/ResponseStatusTest.php @@ -20,6 +20,16 @@ public function itCanTestResponeseAssertOk() $response->assertOk(); } + /** + * @test + */ + public function itCanTestResponeseAssertCreate() + { + $response = new TestResponse(new Response('test', 201, [])); + + $response->assertCreated(); + } + /** * @test */ @@ -30,6 +40,36 @@ public function itCanTestResponeseAssertNoContent() $response->assertNoContent(); } + /** + * @test + */ + public function itCanTestResponeseAssertBadRequest() + { + $response = new TestResponse(new Response('', 400, [])); + + $response->assertBadRequest(); + } + + /** + * @test + */ + public function itCanTestResponeseAssertUnauthorized() + { + $response = new TestResponse(new Response('', 401, [])); + + $response->assertUnauthorized(); + } + + /** + * @test + */ + public function itCanTestResponeseAssertForbidden() + { + $response = new TestResponse(new Response('', 403, [])); + + $response->assertForbidden(); + } + /** * @test */