File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ public function test_parse_shorthand_int(): void
8181 {
8282 self ::assertEquals (null , parse_shorthand_int ("foo " ));
8383 self ::assertEquals (-1 , parse_shorthand_int ("-1 " ));
84+ self ::assertEquals (0 , parse_shorthand_int ("0 " ));
8485 self ::assertEquals (33554432 , parse_shorthand_int ("32M " ));
8586 self ::assertEquals (44441 , parse_shorthand_int ("43.4KB " ));
8687 self ::assertEquals (1231231231 , parse_shorthand_int ("1231231231 " ));
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public static function postToSettings(QueryArray $post): array
5959 $ settings [$ key ] = $ value ;
6060 } elseif ($ type === "int " ) {
6161 assert (!is_array ($ value ));
62- $ settings [$ key ] = $ value ? parse_shorthand_int ($ value ) : null ;
62+ $ settings [$ key ] = $ value !== null ? parse_shorthand_int ($ value ) : null ;
6363 } elseif ($ type === "bool " ) {
6464 $ settings [$ key ] = $ value === "on " ;
6565 } elseif ($ type === "array " ) {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ final class SetupTest extends ShimmiePHPUnitTestCase
88{
99 public function testParseSettings (): void
1010 {
11- self ::assertEquals (
11+ self ::assertSame (
1212 [
1313 "mynull " => null ,
1414 "mystring " => "hello world! " ,
@@ -18,8 +18,8 @@ public function testParseSettings(): void
1818 "myarray " => ["hello " , "world " ],
1919 "emptystring " => null ,
2020 "emptyint " => null ,
21- "emptybool " => null ,
2221 "emptyarray " => null ,
22+ "zero " => 0 ,
2323 ],
2424 ConfigSaveEvent::postToSettings (new QueryArray ([
2525 // keys in POST that don't start with _type or _config are ignored
@@ -44,10 +44,11 @@ public function testParseSettings(): void
4444 "_config_emptystring " => "" ,
4545 "_type_emptyint " => "int " ,
4646 "_config_emptyint " => "" ,
47- "_type_emptybool " => "bool " ,
48- "_config_emptybool " => "" ,
4947 "_type_emptyarray " => "array " ,
5048 "_config_emptyarray " => "" ,
49+ // "0" should not be null
50+ "_type_zero " => "int " ,
51+ "_config_zero " => "0 " ,
5152 ]))
5253 );
5354
You can’t perform that action at this time.
0 commit comments