Skip to content

Commit

Permalink
Improve status exception test
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Dec 11, 2023
1 parent 2105d8e commit 7462113
Showing 1 changed file with 69 additions and 4 deletions.
73 changes: 69 additions & 4 deletions tests/Exception/Http/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ public static function dataGetClass() {
*
* @dataProvider dataInstantiateHttpException
*
* @param mixed $code HTTP status code.
* @param int $code HTTP status code.
*
* @return void
*/
public function testInstantiateHttpException($code) {
$exception_class = Http::get_class($code);
public function testInstantiateHttpException($status_code, $expected_exception_class) {
$exception_class = Http::get_class($status_code);
$exception_object = new $exception_class('testing-1-2-3');
$this->assertInstanceOf(Http::class, $exception_object);
$this->assertInstanceOf($expected_exception_class, $exception_object);
}

/**
Expand All @@ -126,6 +127,70 @@ public function testInstantiateHttpException($code) {
* @return array
*/
public static function dataInstantiateHttpException() {
return array_keys(HttpStatus::MAP);
return [
'100' => [100, Http\StatusUnknown::class],
'101' => [101, Http\StatusUnknown::class],
'102' => [102, Http\StatusUnknown::class],
'103' => [103, Http\StatusUnknown::class],
'200' => [200, Http\StatusUnknown::class],
'201' => [201, Http\StatusUnknown::class],
'202' => [202, Http\StatusUnknown::class],
'203' => [203, Http\StatusUnknown::class],
'204' => [204, Http\StatusUnknown::class],
'205' => [205, Http\StatusUnknown::class],
'206' => [206, Http\StatusUnknown::class],
'207' => [207, Http\StatusUnknown::class],
'208' => [208, Http\StatusUnknown::class],
'226' => [226, Http\StatusUnknown::class],
'300' => [300, Http\StatusUnknown::class],
'301' => [301, Http\StatusUnknown::class],
'302' => [302, Http\StatusUnknown::class],
'303' => [303, Http\StatusUnknown::class],
'304' => [304, Http\Status304::class],
'305' => [305, Http\Status305::class],
'306' => [306, Http\Status306::class],
'307' => [307, Http\StatusUnknown::class],
'308' => [308, Http\StatusUnknown::class],
'400' => [400, Http\Status400::class],
'401' => [401, Http\Status401::class],
'402' => [402, Http\Status402::class],
'403' => [403, Http\Status403::class],
'404' => [404, Http\Status404::class],
'405' => [405, Http\Status405::class],
'406' => [406, Http\Status406::class],
'407' => [407, Http\Status407::class],
'408' => [408, Http\Status408::class],
'409' => [409, Http\Status409::class],
'410' => [410, Http\Status410::class],
'411' => [411, Http\Status411::class],
'412' => [412, Http\Status412::class],
'413' => [413, Http\Status413::class],
'414' => [414, Http\Status414::class],
'415' => [415, Http\Status415::class],
'416' => [416, Http\Status416::class],
'417' => [417, Http\Status417::class],
'418' => [418, Http\Status418::class],
'421' => [421, Http\Status421::class],
'422' => [422, Http\Status422::class],
'423' => [423, Http\Status423::class],
'424' => [424, Http\Status424::class],
'425' => [425, Http\Status425::class],
'426' => [426, Http\Status426::class],
'428' => [428, Http\Status428::class],
'429' => [429, Http\Status429::class],
'431' => [431, Http\Status431::class],
'451' => [451, Http\Status451::class],
'500' => [500, Http\Status500::class],
'501' => [501, Http\Status501::class],
'502' => [502, Http\Status502::class],
'503' => [503, Http\Status503::class],
'504' => [504, Http\Status504::class],
'505' => [505, Http\Status505::class],
'506' => [506, Http\Status506::class],
'507' => [507, Http\Status507::class],
'508' => [508, Http\Status508::class],
'510' => [510, Http\Status510::class],
'511' => [511, Http\Status511::class],
];
}
}

0 comments on commit 7462113

Please sign in to comment.