@@ -1460,6 +1460,20 @@ public function testCanDehydrateAndHydrateComponentsWithEmptyAttributes(): void
14601460 $ this ->assertSame ([], $ actualAttributes ->all ());
14611461 }
14621462
1463+ /**
1464+ * @dataProvider truthyValueProvider
1465+ */
1466+ public function testCoerceTruthyValuesForScalarTypes ($ prop , $ value , $ expected ): void
1467+ {
1468+ $ dehydratedProps = $ this ->dehydrateComponent ($ this ->mountComponent ('scalar_types ' ))->getProps ();
1469+
1470+ $ updatedProps = [$ prop => $ value ];
1471+ $ hydratedComponent = $ this ->getComponent ('scalar_types ' );
1472+ $ this ->hydrateComponent ($ hydratedComponent , 'scalar_types ' , $ dehydratedProps , $ updatedProps );
1473+
1474+ $ this ->assertSame ($ expected , $ hydratedComponent ->$ prop );
1475+ }
1476+
14631477 /**
14641478 * @dataProvider falseyValueProvider
14651479 */
@@ -1474,6 +1488,15 @@ public function testCoerceFalseyValuesForScalarTypes($prop, $value, $expected):
14741488 $ this ->assertSame ($ expected , $ hydratedComponent ->$ prop );
14751489 }
14761490
1491+ public static function truthyValueProvider (): iterable
1492+ {
1493+ yield ['int ' , '1 ' , 1 ];
1494+ yield ['float ' , '1 ' , 1.0 ];
1495+ yield ['float ' , 'true ' , 0.0 ];
1496+ yield ['bool ' , 'true ' , true ];
1497+ yield ['bool ' , '1 ' , true ];
1498+ }
1499+
14771500 public static function falseyValueProvider (): iterable
14781501 {
14791502 yield ['int ' , '' , 0 ];
@@ -1484,6 +1507,7 @@ public static function falseyValueProvider(): iterable
14841507 yield ['float ' , 'apple ' , 0.0 ];
14851508 yield ['bool ' , '' , false ];
14861509 yield ['bool ' , ' ' , false ];
1510+ yield ['bool ' , 'false ' , false ];
14871511
14881512 yield ['nullableInt ' , '' , null ];
14891513 yield ['nullableInt ' , ' ' , null ];
0 commit comments