-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathExtUvLoopTest.php
93 lines (85 loc) · 3.07 KB
/
ExtUvLoopTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace React\Tests\EventLoop;
use React\EventLoop\ExtUvLoop;
class ExtUvLoopTest extends AbstractLoopTest
{
public function createLoop()
{
if (!function_exists('uv_loop_new')) {
$this->markTestSkipped('uv tests skipped because ext-uv is not installed.');
}
return new ExtUvLoop();
}
/** @dataProvider intervalProvider */
public function testTimerInterval($interval, $expectedExceptionMessage)
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($expectedExceptionMessage);
$this->loop
->addTimer(
$interval,
function () {
return 0;
}
);
}
public function intervalProvider()
{
$oversizeInterval = PHP_INT_MAX / 1000;
$maxValue = (int) (PHP_INT_MAX / 1000);
$oneMaxValue = $maxValue + 1;
$tenMaxValue = $maxValue + 10;
$tenMillionsMaxValue = $maxValue + 10000000;
$intMax = PHP_INT_MAX;
$oneIntMax = PHP_INT_MAX + 1;
$tenIntMax = PHP_INT_MAX + 10;
$oneHundredIntMax = PHP_INT_MAX + 100;
$oneThousandIntMax = PHP_INT_MAX + 1000;
$tenMillionsIntMax = PHP_INT_MAX + 10000000;
$tenThousandsTimesIntMax = PHP_INT_MAX * 1000;
yield [
$oversizeInterval,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
];
yield [
$oneMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
];
yield [
$tenMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
];
yield [
$tenMillionsMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
];
yield [
$intMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
];
yield [
$oneIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
];
yield [
$tenIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
];
yield [
$oneHundredIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
];
yield [
$oneThousandIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
];
yield [
$tenMillionsIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
];
yield [
$tenThousandsTimesIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
];
}
}