Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
SonyPradana committed Oct 8, 2023
1 parent eba1858 commit 47a6c43
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/System/Integrate/Testing/Traits/ResponseStatusTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
40 changes: 40 additions & 0 deletions tests/Integrate/Testing/Traits/ResponseStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ public function itCanTestResponeseAssertOk()
$response->assertOk();
}

/**
* @test
*/
public function itCanTestResponeseAssertCreate()
{
$response = new TestResponse(new Response('test', 201, []));

$response->assertCreated();
}

/**
* @test
*/
Expand All @@ -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
*/
Expand Down

0 comments on commit 47a6c43

Please sign in to comment.