|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Utility - Collection of various PHP utility functions. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Eric Sizemore <[email protected]> |
|
9
|
|
|
* @version 2.0.0 |
|
10
|
|
|
* @copyright (C) 2017 - 2024 Eric Sizemore |
|
11
|
|
|
* @license The MIT License (MIT) |
|
12
|
|
|
* |
|
13
|
|
|
* Copyright (C) 2017 - 2024 Eric Sizemore <https://www.secondversion.com>. |
|
14
|
|
|
* |
|
15
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
16
|
|
|
* of this software and associated documentation files (the "Software"), to |
|
17
|
|
|
* deal in the Software without restriction, including without limitation the |
|
18
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
19
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is |
|
20
|
|
|
* furnished to do so, subject to the following conditions: |
|
21
|
|
|
* |
|
22
|
|
|
* The above copyright notice and this permission notice shall be included in |
|
23
|
|
|
* all copies or substantial portions of the Software. |
|
24
|
|
|
* |
|
25
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
26
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
27
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
28
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
29
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
30
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
31
|
|
|
* THE SOFTWARE. |
|
32
|
|
|
*/ |
|
33
|
|
|
|
|
34
|
|
|
namespace Esi\Utility\Tests\Enums\Http; |
|
35
|
|
|
|
|
36
|
|
|
use Esi\Utility\Enums\Http\StatusCodeDescriptions; |
|
37
|
|
|
use PHPUnit\Framework\TestCase; |
|
38
|
|
|
use PHPUnit\Framework\Attributes\CoversClass; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* StatusCodeDescriptions enum tests. |
|
42
|
|
|
* |
|
43
|
|
|
* @todo The tests need some work, more detailed testing. |
|
44
|
|
|
*/ |
|
45
|
|
|
#[CoversClass(StatusCodeDescriptions::class)] |
|
46
|
|
|
class StatusCodeDescriptionsTest extends TestCase |
|
47
|
|
|
{ |
|
48
|
|
|
/** |
|
49
|
|
|
* Holds all cases of the StatusCodeDescriptions enum. |
|
50
|
|
|
* |
|
51
|
|
|
* @var array<int, StatusCodeDescriptions> |
|
52
|
|
|
*/ |
|
53
|
|
|
protected array $descriptions; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Build the $descriptions array. |
|
57
|
|
|
*/ |
|
58
|
|
|
#[\Override] |
|
59
|
|
|
public function setUp(): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->descriptions = StatusCodeDescriptions::cases(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Simple, perhaps unnecessary, test to make sure no empty values. |
|
66
|
|
|
*/ |
|
67
|
|
|
public function testNoneEmpty(): void |
|
68
|
|
|
{ |
|
69
|
|
|
self::assertNotEmpty($this->descriptions); |
|
70
|
|
|
|
|
71
|
|
|
foreach ($this->descriptions as $description) { |
|
72
|
|
|
self::assertNotEmpty($description->getValue()); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Test the getName() method. |
|
78
|
|
|
*/ |
|
79
|
|
|
public function testGetName(): void |
|
80
|
|
|
{ |
|
81
|
|
|
self::assertNotEmpty($this->descriptions); |
|
82
|
|
|
|
|
83
|
|
|
foreach ($this->descriptions as $description) { |
|
84
|
|
|
self::assertSame($description->getName(), $description->name); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|