Skip to content

Commit

Permalink
Rewrite instantiation test
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Jan 8, 2024
1 parent 0519f91 commit fe2e03e
Showing 1 changed file with 15 additions and 65 deletions.
80 changes: 15 additions & 65 deletions tests/Exception/Http/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public static function dataGetClass() {
/**
* Test whether all HTTP exception class can be instantiated.
*
* We're making sure that if such an exception gets triggered, it will not
* fatal because of a broken exception class.
*
* @dataProvider dataInstantiateHttpException
*
* @param int status_code HTTP status code.
Expand All @@ -128,70 +131,17 @@ public function testInstantiateHttpException($status_code, $expected_exception_c
* @return array
*/
public static function dataInstantiateHttpException() {
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],
];
$all_status_codes = array_keys(HttpStatus::MAP);
$non_exception_codes = [100, 101, 102, 103, 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, 300, 301, 302, 303, 307, 308];

$data = [];
foreach ($all_status_codes as $status) {
$classname = in_array($status, $non_exception_codes, true)
? StatusUnknown::class
: Http::class . '\Status' . $status;
$data['Status ' . $status] = [$status, $classname];
}

return $data;
}
}

0 comments on commit fe2e03e

Please sign in to comment.