|
3 | 3 | namespace React\Tests\Stream; |
4 | 4 |
|
5 | 5 | use React\Stream\DuplexResourceStream; |
6 | | -use React\EventLoop as rel; |
7 | 6 | use React\Stream\ReadableResourceStream; |
| 7 | +use React\EventLoop\ExtEventLoop; |
| 8 | +use React\EventLoop\ExtLibeventLoop; |
| 9 | +use React\EventLoop\ExtLibevLoop; |
| 10 | +use React\EventLoop\LoopInterface; |
| 11 | +use React\EventLoop\LibEventLoop; |
| 12 | +use React\EventLoop\LibEvLoop; |
| 13 | +use React\EventLoop\StreamSelectLoop; |
8 | 14 |
|
9 | 15 | class DuplexResourceStreamIntegrationTest extends TestCase |
10 | 16 | { |
11 | 17 | public function loopProvider() |
12 | 18 | { |
13 | 19 | return array( |
14 | | - array(function() { return true; }, function() { return new rel\StreamSelectLoop; }), |
15 | | - array(function() { return function_exists('event_base_new'); }, function() { return new rel\LibEventLoop; }), |
16 | | - array(function() { return class_exists('libev\EventLoop'); }, function() { return new rel\LibEvLoop; }), |
17 | | - array(function() { return class_exists('EventBase'); }, function() { return new rel\ExtEventLoop; }) |
| 20 | + array( |
| 21 | + function() { |
| 22 | + return true; |
| 23 | + }, |
| 24 | + function () { |
| 25 | + return new StreamSelectLoop(); |
| 26 | + } |
| 27 | + ), |
| 28 | + array( |
| 29 | + function () { |
| 30 | + return function_exists('event_base_new'); |
| 31 | + }, |
| 32 | + function () { |
| 33 | + return class_exists('React\EventLoop\ExtLibeventLoop') ? new ExtLibeventLoop() : LibEventLoop(); |
| 34 | + } |
| 35 | + ), |
| 36 | + array( |
| 37 | + function () { |
| 38 | + return class_exists('libev\EventLoop'); |
| 39 | + }, |
| 40 | + function () { |
| 41 | + return class_exists('React\EventLoop\ExtLibevLoop') ? new ExtLibevLoop() : new LibEvLoop(); |
| 42 | + } |
| 43 | + ), |
| 44 | + array( |
| 45 | + function () { |
| 46 | + return class_exists('EventBase') && class_exists('React\EventLoop\ExtEventLoop'); |
| 47 | + }, |
| 48 | + function () { |
| 49 | + return new ExtEventLoop(); |
| 50 | + } |
| 51 | + ) |
18 | 52 | ); |
19 | 53 | } |
20 | 54 |
|
@@ -44,9 +78,9 @@ public function testBufferReadsLargeChunks($condition, $loopFactory) |
44 | 78 |
|
45 | 79 | $streamA->write($testString); |
46 | 80 |
|
47 | | - $loop->tick(); |
48 | | - $loop->tick(); |
49 | | - $loop->tick(); |
| 81 | + $this->loopTick($loop); |
| 82 | + $this->loopTick($loop); |
| 83 | + $this->loopTick($loop); |
50 | 84 |
|
51 | 85 | $streamA->close(); |
52 | 86 | $streamB->close(); |
@@ -307,4 +341,12 @@ public function testReadsNothingFromProcessPipeWithNoOutput($condition, $loopFac |
307 | 341 |
|
308 | 342 | $loop->run(); |
309 | 343 | } |
| 344 | + |
| 345 | + private function loopTick(LoopInterface $loop) |
| 346 | + { |
| 347 | + $loop->addTimer(0, function () use ($loop) { |
| 348 | + $loop->stop(); |
| 349 | + }); |
| 350 | + $loop->run(); |
| 351 | + } |
310 | 352 | } |
0 commit comments