@@ -30,4 +30,48 @@ public function testCastToBool($input, ?bool $mappedValue)
3030
3131 $ this ->assertSame ($ mappedValue , $ result );
3232 }
33+
34+ public static function intProvider (): array
35+ {
36+ return [
37+ 'integer ' => [1 , 1 ],
38+ 'string integer ' => ['11 ' , 11 ],
39+ 'null ' => [null , null ],
40+ 'empty string ' => ['' , null ],
41+ 'zero ' => [0 , 0 ],
42+ 'invalid ' => [false , null ],
43+ ];
44+ }
45+
46+ /**
47+ * @dataProvider intProvider
48+ */
49+ public function testCastToInt ($ input , ?int $ mappedValue )
50+ {
51+ $ result = Caster::castToInt ($ input );
52+
53+ $ this ->assertSame ($ mappedValue , $ result );
54+ }
55+
56+ public static function floatProvider (): array
57+ {
58+ return [
59+ 'float ' => [1.1 , 1.1 ],
60+ 'string floateger ' => ['2.2 ' , 2.2 ],
61+ 'null ' => [null , null ],
62+ 'empty string ' => ['' , null ],
63+ 'zero ' => [0 , 0 ],
64+ 'invalid ' => [false , null ],
65+ ];
66+ }
67+
68+ /**
69+ * @dataProvider floatProvider
70+ */
71+ public function testCastToFloat ($ input , ?float $ mappedValue )
72+ {
73+ $ result = Caster::castToFloat ($ input );
74+
75+ $ this ->assertSame ($ mappedValue , $ result );
76+ }
3377}
0 commit comments