@@ -24,34 +24,30 @@ private function deleteKey(string $index): void
2424 public static function getGarbageIndexArgs ()
2525 {
2626 global $ HTTP_HEADER_TEST_INPUTS ;
27- return array_map (function ($ x ) {
28- return [$ x ];
29- }, $ HTTP_HEADER_TEST_INPUTS );
27+ $ http_header_test_inputs_no_ints = array_filter (
28+ $ HTTP_HEADER_TEST_INPUTS ,
29+ fn ($ x ) => !ctype_digit ($ x ),
30+ );
31+ $ http_header_test_inputs_no_ints_2d = array_map (
32+ fn ($ x ) => [$ x ],
33+ $ http_header_test_inputs_no_ints ,
34+ );
35+ return array_merge ([["-1 " ], ["0.5 " ]], $ http_header_test_inputs_no_ints_2d );
3036 }
3137
3238 #[DataProvider("getGarbageIndexArgs " )]
3339 public function testDeleteKeyGarbageInput (string $ index )
3440 {
3541 global $ USER ;
3642 try {
43+ $ this ->expectException (ValueError::class);
3744 $ this ->deleteKey ($ index );
3845 $ this ->assertEquals (self ::$ initialKeys , $ USER ->getSSHKeys ());
3946 } finally {
4047 $ USER ->setSSHKeys (self ::$ initialKeys );
4148 }
4249 }
4350
44- public function testDeleteKeyNegativeIndex ()
45- {
46- global $ USER ;
47- try {
48- $ this ->deleteKey ("-1 " );
49- $ this ->assertEquals (self ::$ initialKeys , $ USER ->getSSHKeys ());
50- } finally {
51- $ USER ->setSSHKeys (self ::$ initialKeys );
52- }
53- }
54-
5551 public function testDeleteKeyIndexTooLarge ()
5652 {
5753 global $ USER ;
@@ -63,17 +59,6 @@ public function testDeleteKeyIndexTooLarge()
6359 }
6460 }
6561
66- public function testDeleteKeyDecimal ()
67- {
68- global $ USER ;
69- try {
70- $ this ->deleteKey ("0.5 " );
71- $ this ->assertEquals (self ::$ initialKeys , $ USER ->getSSHKeys ());
72- } finally {
73- $ USER ->setSSHKeys (self ::$ initialKeys );
74- }
75- }
76-
7762 public function testDeleteKey ()
7863 {
7964 global $ USER ;
0 commit comments