|
18 | 18 | use function uniqid; |
19 | 19 |
|
20 | 20 | use const PHP_INT_MAX; |
| 21 | +use const PHP_VERSION_ID; |
21 | 22 |
|
22 | 23 | /** |
23 | 24 | * @group rule |
|
31 | 32 | */ |
32 | 33 | final class FactorTest extends RuleTestCase |
33 | 34 | { |
| 35 | + /** |
| 36 | + * Some edge cases emit E_DEPRECATED on PHP >= 8.5. |
| 37 | + * |
| 38 | + * @test |
| 39 | + * |
| 40 | + * @dataProvider providerForInvalidInputEdgeCases |
| 41 | + */ |
| 42 | + public function shouldFailOnInvalidInputEdgeCases(Factor $rule, mixed $input): void |
| 43 | + { |
| 44 | + if (PHP_VERSION_ID >= 80500) { |
| 45 | + $this->markTestSkipped('This test emits E_DEPRECATED on PHP >= 8.5'); |
| 46 | + } |
| 47 | + |
| 48 | + self::assertInvalidInput($rule, $input); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * @return array<string, array{0:Factor, 1:mixed}> |
| 53 | + */ |
| 54 | + public static function providerForInvalidInputEdgeCases(): array |
| 55 | + { |
| 56 | + return [ |
| 57 | + 'mt_rand is not factor PHP_INT_MAX + 1' => [new Factor(mt_rand()), PHP_INT_MAX + 1], |
| 58 | + ]; |
| 59 | + } |
| 60 | + |
34 | 61 | /** |
35 | 62 | * {@inheritDoc} |
36 | 63 | */ |
@@ -93,7 +120,6 @@ public static function providerForInvalidInput(): array |
93 | 120 | 'mt_rand is not factor 1.5' => [new Factor(mt_rand()), 1.5], |
94 | 121 | 'mt_rand is not factor -0.5' => [new Factor(mt_rand()), -0.5], |
95 | 122 | 'mt_rand is not factor -1.5' => [new Factor(mt_rand()), -1.5], |
96 | | - 'mt_rand is not factor PHP_INT_MAX + 1' => [new Factor(mt_rand()), PHP_INT_MAX + 1], |
97 | 123 | 'mt_rand is not factor calc' => [new Factor(mt_rand()), mt_rand(1, mt_getrandmax() - 1) / mt_getrandmax()], |
98 | 124 | 'mt_rand is not factor -calc' => [ |
99 | 125 | new Factor(mt_rand()), |
|
0 commit comments