Skip to content

Commit 6aeed57

Browse files
committed
Forward compatibility with react/event-loop 1.0 and 0.5 while still supporting 0.4 - part deux
1 parent 404f8e2 commit 6aeed57

File tree

7 files changed

+100
-30
lines changed

7 files changed

+100
-30
lines changed

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Node/Directory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace React\Filesystem\Node;
44

55
use Evenement\EventEmitterTrait;
6-
use React\EventLoop\Timer\TimerInterface;
76
use React\Filesystem\AdapterInterface;
87
use React\Filesystem\FilesystemInterface;
98
use React\Filesystem\ObjectStream;
@@ -258,9 +257,9 @@ protected function processLsRecursiveContents($sourceStream)
258257
});
259258

260259
$sourceStream->on('end', function () use (&$closeCount, $stream) {
261-
$this->adapter->getLoop()->addPeriodicTimer(0.01, function (TimerInterface $timer) use (&$closeCount, $stream) {
260+
$this->adapter->getLoop()->addPeriodicTimer(0.01, function ($timer) use (&$closeCount, $stream) {
262261
if ($closeCount === 0) {
263-
$timer->cancel();
262+
$this->adapter->getLoop()->cancelTimer($timer);
264263
$stream->close();
265264
}
266265
});

tests/Eio/AdapterTest.php

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,23 @@ public function _testOpen($loop, $adapter, $invoker)
441441

442442
public function testExecuteDelayedCall()
443443
{
444-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop', [
445-
'futureTick',
444+
$loop = $this->getMock('React\EventLoop\LoopInterface', [
446445
'addReadStream',
446+
'addWriteStream',
447+
'removeReadStream',
448+
'removeWriteStream',
449+
'removeStream',
450+
'addTimer',
451+
'addPeriodicTimer',
452+
'cancelTimer',
453+
'isTimerActive',
454+
'nextTick',
455+
'futureTick',
456+
'tick',
457+
'run',
458+
'stop',
459+
'addSignal',
460+
'removeSignal',
447461
]);
448462

449463
$filesystem = new Adapter($loop);
@@ -486,9 +500,23 @@ public function testExecuteDelayedCall()
486500

487501
public function testExecuteDelayedCallFailed()
488502
{
489-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop', [
490-
'futureTick',
503+
$loop = $this->getMock('React\EventLoop\LoopInterface', [
491504
'addReadStream',
505+
'addWriteStream',
506+
'removeReadStream',
507+
'removeWriteStream',
508+
'removeStream',
509+
'addTimer',
510+
'addPeriodicTimer',
511+
'cancelTimer',
512+
'isTimerActive',
513+
'nextTick',
514+
'futureTick',
515+
'tick',
516+
'run',
517+
'stop',
518+
'addSignal',
519+
'removeSignal',
492520
]);
493521

494522
$filesystem = new Adapter($loop);
@@ -529,9 +557,23 @@ public function testExecuteDelayedCallFailed()
529557

530558
public function testExecuteDelayedCallFailedResult()
531559
{
532-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop', [
533-
'futureTick',
560+
$loop = $this->getMock('React\EventLoop\LoopInterface', [
534561
'addReadStream',
562+
'addWriteStream',
563+
'removeReadStream',
564+
'removeWriteStream',
565+
'removeStream',
566+
'addTimer',
567+
'addPeriodicTimer',
568+
'cancelTimer',
569+
'isTimerActive',
570+
'nextTick',
571+
'futureTick',
572+
'tick',
573+
'run',
574+
'stop',
575+
'addSignal',
576+
'removeSignal',
535577
]);
536578

537579
$filesystem = new Adapter($loop);
@@ -572,9 +614,23 @@ public function testExecuteDelayedCallFailedResult()
572614

573615
public function testUnregister()
574616
{
575-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop', [
576-
'futureTick',
617+
$loop = $this->getMock('React\EventLoop\LoopInterface', [
618+
'addReadStream',
619+
'addWriteStream',
577620
'removeReadStream',
621+
'removeWriteStream',
622+
'removeStream',
623+
'addTimer',
624+
'addPeriodicTimer',
625+
'cancelTimer',
626+
'isTimerActive',
627+
'nextTick',
628+
'futureTick',
629+
'tick',
630+
'run',
631+
'stop',
632+
'addSignal',
633+
'removeSignal',
578634
]);
579635

580636
$filesystem = $this->getMock('React\Filesystem\Eio\Adapter', [
@@ -625,8 +681,23 @@ public function testUnregister()
625681

626682
public function testUnregisterInactive()
627683
{
628-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop', [
684+
$loop = $this->getMock('React\EventLoop\LoopInterface', [
685+
'addReadStream',
686+
'addWriteStream',
629687
'removeReadStream',
688+
'removeWriteStream',
689+
'removeStream',
690+
'addTimer',
691+
'addPeriodicTimer',
692+
'cancelTimer',
693+
'isTimerActive',
694+
'nextTick',
695+
'futureTick',
696+
'tick',
697+
'run',
698+
'stop',
699+
'addSignal',
700+
'removeSignal',
630701
]);
631702

632703
$filesystem = $this->getMock('React\Filesystem\Eio\Adapter', [

tests/Eio/ConstTypeDetectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testDetect($const, $method)
3232
{
3333
$callbackFired = false;
3434

35-
$filesystem = Filesystem::create($this->getMock('React\EventLoop\StreamSelectLoop'), [
35+
$filesystem = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
3636
'pool' => [
3737
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
3838
],
@@ -54,7 +54,7 @@ public function testDetectUnknown()
5454
{
5555
$callbackFired = false;
5656

57-
$filesystem = Filesystem::create($this->getMock('React\EventLoop\StreamSelectLoop'), [
57+
$filesystem = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
5858
'pool' => [
5959
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
6060
],

tests/FilesystemTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function testCreate()
1313
{
1414
$this->assertInstanceOf(
1515
'React\Filesystem\Filesystem',
16-
Filesystem::create($this->getMock('React\EventLoop\StreamSelectLoop'), [
16+
Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
1717
'pool' => [
1818
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
1919
],
@@ -45,7 +45,7 @@ public function testFactory()
4545

4646
public function testFile()
4747
{
48-
$file = Filesystem::create($this->getMock('React\EventLoop\StreamSelectLoop'), [
48+
$file = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
4949
'pool' => [
5050
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
5151
],
@@ -56,7 +56,7 @@ public function testFile()
5656

5757
public function testDir()
5858
{
59-
$directory = Filesystem::create($this->getMock('React\EventLoop\StreamSelectLoop'), [
59+
$directory = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
6060
'pool' => [
6161
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
6262
],

tests/Node/DirectoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testGetPath()
4141
public function testLs()
4242
{
4343
$path = '/home/foo/bar';
44-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop');
44+
$loop = $this->getMock('React\EventLoop\LoopInterface');
4545

4646
$filesystem = $this->mockAdapter($loop);
4747

@@ -118,7 +118,7 @@ public function testRemove()
118118
public function testSize()
119119
{
120120
$path = '/home/foo/bar';
121-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop');
121+
$loop = $this->getMock('React\EventLoop\LoopInterface');
122122

123123
$filesystem = $this->mockAdapter($loop);
124124

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestCase extends PHPUnitTestCase
1818
protected function mockAdapter(LoopInterface $loop = null)
1919
{
2020
if ($loop === null) {
21-
$loop = $this->getMock('React\EventLoop\StreamSelectLoop');
21+
$loop = $this->getMock('React\EventLoop\LoopInterface');
2222
}
2323

2424
$mock = $this->getMock('React\Filesystem\AdapterInterface', [

0 commit comments

Comments
 (0)