@@ -22,9 +22,6 @@ public function testAddTimerReturnsNonPeriodicTimerInstance()
22
22
$ this ->assertFalse ($ timer ->isPeriodic ());
23
23
}
24
24
25
- /**
26
- * @depends testPlatformHasHighAccuracy
27
- */
28
25
public function testAddTimerWillBeInvokedOnceAndBlocksLoopWhenRunning ()
29
26
{
30
27
// Make no strict assumptions about actual time interval. Common
@@ -46,14 +43,15 @@ public function testAddTimerWillBeInvokedOnceAndBlocksLoopWhenRunning()
46
43
47
44
$ loop = $ this ->createLoop ();
48
45
49
- $ loop ->addTimer (0.001 , $ this ->expectCallableOnce ());
46
+ $ loop ->addTimer (0.002 , $ this ->expectCallableOnce ());
50
47
51
48
$ start = microtime (true );
52
49
$ loop ->run ();
53
50
$ end = microtime (true );
54
51
52
+ // 1 invocation should take 2ms (± 1ms due to timer inaccuracies)
55
53
$ this ->assertGreaterThanOrEqual (0.001 , $ end - $ start );
8000
code>
56
- $ this ->assertLessThan (0.002 , $ end - $ start );
54
+ $ this ->assertLessThan (0.003 , $ end - $ start );
57
55
}
58
56
59
57
public function testAddPeriodicTimerReturnsPeriodicTimerInstance ()
@@ -122,10 +120,10 @@ public function testAddPeriodicTimerCancelsItself()
122
120
123
121
$ this ->assertEquals (5 , $ i );
124
122
125
- // make no strict assumptions about time interval.
126
- // 5 invocations must take at least 0.005s (5ms) and should not take
127
- // longer than 0.1s for slower loops.
128
- $ this ->assertGreaterThanOrEqual (0.005 , $ end - $ start );
123
+ // 5 invocations should take 5ms (± 1ms due to timer inaccuracies)
124
+ // make no strict assumptions about time interval, must at least take 4ms
125
+ // and should not take longer than 0.1s for slower loops.
126
+ $ this ->assertGreaterThanOrEqual (0.004 , $ end - $ start );
129
127
$ this ->assertLessThan (0.1 , $ end - $ start );
130
128
}
131
129
0 commit comments