Skip to content

Commit bac7502

Browse files
Added more tests
1 parent e2c8840 commit bac7502

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/phpunit/Builder/BuilderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
1717
*/
1818

19+
use Illuminate\Http\JsonResponse;
1920
use MarcinOrlowski\PhpunitExtraAsserts\Generator;
2021
use MarcinOrlowski\ResponseBuilder\BaseApiCodes;
2122
use MarcinOrlowski\ResponseBuilder\Builder;
@@ -89,4 +90,15 @@ public function testErrorWithOkCode(): void
8990
RB::asError(BaseApiCodes::OK());
9091
}
9192

93+
/**
94+
* Checksi if explicit @null as HTTP code falls back to default HTTP error code..
95+
*/
96+
public function testErrorWithNullHttpCode(): void
97+
{
98+
$apiCode = BaseApiCodes::getMinCode();
99+
$response = RB::error($apiCode, http_code: null);
100+
$this->assertInstanceOf(JsonResponse::class, $response);
101+
$this->assertEquals(RB::DEFAULT_HTTP_CODE_ERROR, $response->getStatusCode());
102+
}
103+
92104
} // end of class

0 commit comments

Comments
 (0)