|
4 | 4 |
|
5 | 5 | use PHPUnit\Framework\TestCase; |
6 | 6 | use PHPUnit\Framework\Attributes\DataProvider; |
7 | | -use UnityWebPortal\lib\exceptions\ArrayKeyException; |
8 | 7 | // use PHPUnit\Framework\Attributes\BackupGlobals; |
9 | 8 | // use PHPUnit\Framework\Attributes\RunTestsInSeparateProcess; |
10 | 9 |
|
@@ -80,82 +79,4 @@ public function testTestValidSSHKey(bool $expected, string $key) |
80 | 79 | { |
81 | 80 | $this->assertEquals($expected, UnitySite::testValidSSHKey($key)); |
82 | 81 | } |
83 | | - |
84 | | - public function testArrayGetReturnsValueWhenKeyExists() |
85 | | - { |
86 | | - $array = [ |
87 | | - "a" => [ |
88 | | - "b" => [ |
89 | | - "c" => 123 |
90 | | - ] |
91 | | - ] |
92 | | - ]; |
93 | | - $result = UnitySite::arrayGet($array, "a", "b", "c"); |
94 | | - $this->assertSame(123, $result); |
95 | | - } |
96 | | - |
97 | | - public function testArrayGetReturnsArrayWhenTraversingPartially() |
98 | | - { |
99 | | - $array = [ |
100 | | - "foo" => [ |
101 | | - "bar" => "baz" |
102 | | - ] |
103 | | - ]; |
104 | | - $result = UnitySite::arrayGet($array, "foo"); |
105 | | - $this->assertSame(["bar" => "baz"], $result); |
106 | | - } |
107 | | - |
108 | | - public function testArrayGetThrowsOnMissingKeyFirstLevel() |
109 | | - { |
110 | | - $array = ["x" => 1]; |
111 | | - $this->expectException(ArrayKeyException::class); |
112 | | - $this->expectExceptionMessage('$array["y"]'); |
113 | | - UnitySite::arrayGet($array, "y"); |
114 | | - } |
115 | | - |
116 | | - public function testArrayGetThrowsOnMissingKeyNested() |
117 | | - { |
118 | | - $array = ["a" => []]; |
119 | | - $this->expectException(ArrayKeyException::class); |
120 | | - // Should include both levels |
121 | | - $this->expectExceptionMessage('$array["a"]["b"]'); |
122 | | - UnitySite::arrayGet($array, "a", "b"); |
123 | | - } |
124 | | - |
125 | | - public function testArrayGetThrowsWhenValueIsNullButKeyNotSet() |
126 | | - { |
127 | | - $array = ["a" => null]; |
128 | | - $this->expectException(ArrayKeyException::class); |
129 | | - $this->expectExceptionMessage('$array["a"]'); |
130 | | - UnitySite::arrayGet($array, "a"); |
131 | | - } |
132 | | - |
133 | | - public function testArrayGetReturnsValueWhenValueIsFalsyButSet() |
134 | | - { |
135 | | - $array = ["a" => 0]; |
136 | | - $result = UnitySite::arrayGet($array, "a"); |
137 | | - $this->assertSame(0, $result); |
138 | | - } |
139 | | - |
140 | | - // I suspect that this test could have unexpected interactions with other tests. |
141 | | - // even with RunTestsInSeparateProcess and BackupGlobalState, http_response_code() |
142 | | - // still persists to the next test. header("HTTP/1.1 false") puts it back to its |
143 | | - // initial value, but this is a hack and does not inspire confidence. |
144 | | - // #[BackupGlobals(true)] |
145 | | - // #[RunTestsInSeparateProcess] |
146 | | - // public function testHeaderResponseCode() |
147 | | - // { |
148 | | - // $this->assertEquals(false, http_response_code()); |
149 | | - // $this->assertArrayNotHasKey("SERVER_PROTOCOL", $_SERVER); |
150 | | - // try { |
151 | | - // $_SERVER["SERVER_PROTOCOL"] = "HTTP/1.1"; |
152 | | - // UnitySite::headerResponseCode(400); |
153 | | - // $this->assertEquals(400, http_response_code()); |
154 | | - // UnitySite::headerResponseCode(401); |
155 | | - // $this->assertEquals(401, http_response_code()); |
156 | | - // } finally { |
157 | | - // unset($_SERVER["SERVER_PROTOCOL"]); |
158 | | - // header("HTTP/1.1 false"); |
159 | | - // } |
160 | | - // } |
161 | 82 | } |
0 commit comments