44
55use PHPUnit \Framework \TestCase ;
66use PHPUnit \Framework \Attributes \DataProvider ;
7- use UnityWebPortal \lib \exceptions \NoDieException ;
7+ use UnityWebPortal \lib \exceptions \ArrayKeyException ;
88// use PHPUnit\Framework\Attributes\BackupGlobals;
99// use PHPUnit\Framework\Attributes\RunTestsInSeparateProcess;
1010
@@ -81,7 +81,7 @@ public function testTestValidSSHKey(bool $expected, string $key)
8181 $ this ->assertEquals ($ expected , UnitySite::testValidSSHKey ($ key ));
8282 }
8383
84- public function testArrayGetOrBadRequestReturnsValueWhenKeyExists ()
84+ public function testArrayGetReturnsValueWhenKeyExists ()
8585 {
8686 $ array = [
8787 "a " => [
@@ -90,50 +90,50 @@ public function testArrayGetOrBadRequestReturnsValueWhenKeyExists()
9090 ]
9191 ]
9292 ];
93- $ result = UnitySite::arrayGetOrBadRequest ($ array , "a " , "b " , "c " );
93+ $ result = UnitySite::arrayGet ($ array , "a " , "b " , "c " );
9494 $ this ->assertSame (123 , $ result );
9595 }
9696
97- public function testArrayGetOrBadRequestReturnsArrayWhenTraversingPartially ()
97+ public function testArrayGetReturnsArrayWhenTraversingPartially ()
9898 {
9999 $ array = [
100100 "foo " => [
101101 "bar " => "baz "
102102 ]
103103 ];
104- $ result = UnitySite::arrayGetOrBadRequest ($ array , "foo " );
104+ $ result = UnitySite::arrayGet ($ array , "foo " );
105105 $ this ->assertSame (["bar " => "baz " ], $ result );
106106 }
107107
108- public function testArrayGetOrBadRequestThrowsOnMissingKeyFirstLevel ()
108+ public function testArrayGetThrowsOnMissingKeyFirstLevel ()
109109 {
110110 $ array = ["x " => 1 ];
111- $ this ->expectException (NoDieException ::class);
112- $ this ->expectExceptionMessage ('["y"] ' );
113- UnitySite::arrayGetOrBadRequest ($ array , "y " );
111+ $ this ->expectException (ArrayKeyException ::class);
112+ $ this ->expectExceptionMessage ('$array ["y"] ' );
113+ UnitySite::arrayGet ($ array , "y " );
114114 }
115115
116- public function testArrayGetOrBadRequestThrowsOnMissingKeyNested ()
116+ public function testArrayGetThrowsOnMissingKeyNested ()
117117 {
118118 $ array = ["a " => []];
119- $ this ->expectException (NoDieException ::class);
119+ $ this ->expectException (ArrayKeyException ::class);
120120 // Should include both levels
121- $ this ->expectExceptionMessage ('["a", "b"] ' );
122- UnitySite::arrayGetOrBadRequest ($ array , "a " , "b " );
121+ $ this ->expectExceptionMessage ('$array ["a"][ "b"] ' );
122+ UnitySite::arrayGet ($ array , "a " , "b " );
123123 }
124124
125- public function testArrayGetOrBadRequestThrowsWhenValueIsNullButKeyNotSet ()
125+ public function testArrayGetThrowsWhenValueIsNullButKeyNotSet ()
126126 {
127127 $ array = ["a " => null ];
128- $ this ->expectException (NoDieException ::class);
129- $ this ->expectExceptionMessage ('["a"] ' );
130- UnitySite::arrayGetOrBadRequest ($ array , "a " );
128+ $ this ->expectException (ArrayKeyException ::class);
129+ $ this ->expectExceptionMessage ('$array ["a"] ' );
130+ UnitySite::arrayGet ($ array , "a " );
131131 }
132132
133- public function testArrayGetOrBadRequestReturnsValueWhenValueIsFalsyButSet ()
133+ public function testArrayGetReturnsValueWhenValueIsFalsyButSet ()
134134 {
135135 $ array = ["a " => 0 ];
136- $ result = UnitySite::arrayGetOrBadRequest ($ array , "a " );
136+ $ result = UnitySite::arrayGet ($ array , "a " );
137137 $ this ->assertSame (0 , $ result );
138138 }
139139
0 commit comments