Skip to content

Commit 8d28bdc

Browse files
authored
Add tests for multipleOf bugs
1 parent dabc147 commit 8d28bdc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/unit/NumberTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public static function validationProvider(): array
4040
[Number::make()->maximum(10, exclusive: true), 10, false],
4141
[Number::make()->multipleOf(2), 1, false],
4242
[Number::make()->multipleOf(2), 2, true],
43+
[Number::make()->multipleOf(0.01), 100, true],
44+
[Number::make()->multipleOf(0.01), 100.5, true],
45+
[Number::make()->multipleOf(0.01), 100.56, true],
46+
[Number::make()->multipleOf(0.01), 100.567, false],
4347
];
4448
}
4549

@@ -56,4 +60,17 @@ public function test_validation(Type $type, mixed $value, bool $valid)
5660

5761
$type->validate($value, $fail);
5862
}
63+
64+
public function test_multipleOf_reset(): void
65+
{
66+
$number = Number::make()
67+
->multipleOf(2)
68+
->multipleOf(null);
69+
70+
$fail = $this->createMock(MockedCaller::class)
71+
->expects($this->never())
72+
->method('__invoke');
73+
74+
$number->validate(5, $fail);
75+
}
5976
}

0 commit comments

Comments
 (0)