|
7 | 7 | use Laminas\Filter\ToInt; |
8 | 8 | use LaminasTest\Filter\TestAsset\StringableObject; |
9 | 9 | use PHPUnit\Framework\Attributes\DataProvider; |
10 | | -use PHPUnit\Framework\Attributes\RequiresPhp; |
11 | 10 | use PHPUnit\Framework\TestCase; |
12 | 11 |
|
13 | | -use function restore_error_handler; |
14 | | -use function set_error_handler; |
15 | | - |
16 | | -use const E_WARNING; |
17 | 12 | use const PHP_INT_MAX; |
18 | 13 |
|
19 | 14 | final class ToIntTest extends TestCase |
@@ -48,35 +43,10 @@ public function testBasicBehaviour(mixed $input, mixed $expect): void |
48 | 43 | self::assertSame($expect, $filter->__invoke($input)); |
49 | 44 | } |
50 | 45 |
|
51 | | - #[RequiresPhp('<= 8.4.99')] |
52 | 46 | public function testHugeNumbersAreTruncatedToIntMax(): void |
53 | 47 | { |
54 | 48 | $huge = '9223372036854775807999'; |
55 | 49 | $filter = new ToInt(); |
56 | 50 | self::assertSame(PHP_INT_MAX, $filter->__invoke($huge)); |
57 | 51 | } |
58 | | - |
59 | | - #[RequiresPhp('>= 8.5.0')] |
60 | | - public function testHugeNumbersAreTruncatedToIntMaxOn85WithAWarning(): void |
61 | | - { |
62 | | - $called = false; |
63 | | - $huge = '9223372036854775807999'; |
64 | | - |
65 | | - set_error_handler(static function (int $code, string $message) use (&$called, $huge): bool { |
66 | | - self::assertSame(E_WARNING, $code); |
67 | | - self::assertStringContainsString($huge, $message); |
68 | | - self::assertStringContainsString('is not representable as an int', $message); |
69 | | - $called = true; |
70 | | - |
71 | | - return true; |
72 | | - }); |
73 | | - |
74 | | - $filter = new ToInt(); |
75 | | - try { |
76 | | - self::assertSame(PHP_INT_MAX, $filter->__invoke($huge)); |
77 | | - self::assertTrue($called, 'The error handler should have been called'); |
78 | | - } finally { |
79 | | - restore_error_handler(); |
80 | | - } |
81 | | - } |
82 | 52 | } |
0 commit comments