Skip to content

Commit a60eba9

Browse files
committed
react/stream 1.0 || 0.7 compatibility
1 parent 707cf28 commit a60eba9

6 files changed

Lines changed: 50 additions & 53 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"require": {
1818
"php": ">=5.3",
19-
"react/stream": "^0.6 || ^0.5 || ^0.4 || ^0.3",
19+
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4 || ^0.3",
2020
"react/promise": "^2.1 || ^1.2"
2121
},
2222
"require-dev": {

tests/AllTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?php
22

33
use React\Promise\Stream;
4-
use React\Stream\ReadableStream;
5-
use React\Stream\WritableStream;
4+
use React\Stream\ThroughStream;
65

76
class AllTest extends TestCase
87
{
98
public function testClosedStreamResolvesWithEmptyBuffer()
109
{
11-
$stream = new ReadableStream();
10+
$stream = new ThroughStream();
1211
$stream->close();
1312

1413
$promise = Stream\all($stream);
@@ -18,7 +17,7 @@ public function testClosedStreamResolvesWithEmptyBuffer()
1817

1918
public function testClosedWritableStreamResolvesWithEmptyBuffer()
2019
{
21-
$stream = new WritableStream();
20+
$stream = new ThroughStream();
2221
$stream->close();
2322

2423
$promise = Stream\all($stream);
@@ -28,7 +27,7 @@ public function testClosedWritableStreamResolvesWithEmptyBuffer()
2827

2928
public function testPendingStreamWillNotResolve()
3029
{
31-
$stream = new ReadableStream();
30+
$stream = new ThroughStream();
3231

3332
$promise = Stream\all($stream);
3433

@@ -37,7 +36,7 @@ public function testPendingStreamWillNotResolve()
3736

3837
public function testClosingStreamResolvesWithEmptyBuffer()
3938
{
40-
$stream = new ReadableStream();
39+
$stream = new ThroughStream();
4140
$promise = Stream\all($stream);
4241

4342
$stream->close();
@@ -47,7 +46,7 @@ public function testClosingStreamResolvesWithEmptyBuffer()
4746

4847
public function testClosingWritableStreamResolvesWithEmptyBuffer()
4948
{
50-
$stream = new WritableStream();
49+
$stream = new ThroughStream();
5150
$promise = Stream\all($stream);
5251

5352
$stream->close();
@@ -57,7 +56,7 @@ public function testClosingWritableStreamResolvesWithEmptyBuffer()
5756

5857
public function testEmittingDataOnStreamResolvesWithArrayOfData()
5958
{
60-
$stream = new ReadableStream();
59+
$stream = new ThroughStream();
6160
$promise = Stream\all($stream);
6261

6362
$stream->emit('data', array('hello', $stream));
@@ -69,7 +68,7 @@ public function testEmittingDataOnStreamResolvesWithArrayOfData()
6968

7069
public function testEmittingErrorOnStreamRejects()
7170
{
72-
$stream = new ReadableStream();
71+
$stream = new ThroughStream();
7372
$promise = Stream\all($stream);
7473

7574
$stream->emit('error', array(new \RuntimeException('test')));
@@ -79,7 +78,7 @@ public function testEmittingErrorOnStreamRejects()
7978

8079
public function testEmittingErrorAfterEmittingDataOnStreamRejects()
8180
{
82-
$stream = new ReadableStream();
81+
$stream = new ThroughStream();
8382
$promise = Stream\all($stream);
8483

8584
$stream->emit('data', array('hello', $stream));
@@ -90,7 +89,7 @@ public function testEmittingErrorAfterEmittingDataOnStreamRejects()
9089

9190
public function testCancelPendingStreamWillReject()
9291
{
93-
$stream = new ReadableStream();
92+
$stream = new ThroughStream();
9493

9594
$promise = Stream\all($stream);
9695

tests/BufferTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

33
use React\Promise\Stream;
4-
use React\Stream\ReadableStream;
4+
use React\Stream\ThroughStream;
55

66
class BufferTest extends TestCase
77
{
88
public function testClosedStreamResolvesWithEmptyBuffer()
99
{
10-
$stream = new ReadableStream();
10+
$stream = new ThroughStream();
1111
$stream->close();
1212

1313
$promise = Stream\buffer($stream);
@@ -17,7 +17,7 @@ public function testClosedStreamResolvesWithEmptyBuffer()
1717

1818
public function testPendingStreamWillNotResolve()
1919
{
20-
$stream = new ReadableStream();
20+
$stream = new ThroughStream();
2121

2222
$promise = Stream\buffer($stream);
2323

@@ -26,7 +26,7 @@ public function testPendingStreamWillNotResolve()
2626

2727
public function testClosingStreamResolvesWithEmptyBuffer()
2828
{
29-
$stream = new ReadableStream();
29+
$stream = new ThroughStream();
3030
$promise = Stream\buffer($stream);
3131

3232
$stream->close();
@@ -36,7 +36,7 @@ public function testClosingStreamResolvesWithEmptyBuffer()
3636

3737
public function testEmittingDataOnStreamResolvesWithConcatenatedData()
3838
{
39-
$stream = new ReadableStream();
39+
$stream = new ThroughStream();
4040
$promise = Stream\buffer($stream);
4141

4242
$stream->emit('data', array('hello', $stream));
@@ -48,7 +48,7 @@ public function testEmittingDataOnStreamResolvesWithConcatenatedData()
4848

4949
public function testEmittingErrorOnStreamRejects()
5050
{
51-
$stream = new ReadableStream();
51+
$stream = new ThroughStream();
5252
$promise = Stream\buffer($stream);
5353

5454
$stream->emit('error', array(new \RuntimeException('test')));
@@ -58,7 +58,7 @@ public function testEmittingErrorOnStreamRejects()
5858

5959
public function testEmittingErrorAfterEmittingDataOnStreamRejects()
6060
{
61-
$stream = new ReadableStream();
61+
$stream = new ThroughStream();
6262
$promise = Stream\buffer($stream);
6363

6464
$stream->emit('data', array('hello', $stream));
@@ -69,7 +69,7 @@ public function testEmittingErrorAfterEmittingDataOnStreamRejects()
6969

7070
public function testCancelPendingStreamWillReject()
7171
{
72-
$stream = new ReadableStream();
72+
$stream = new ThroughStream();
7373

7474
$promise = Stream\buffer($stream);
7575

tests/FirstTest.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?php
22

33
use React\Promise\Stream;
4-
use React\Stream\ReadableStream;
5-
use React\Stream\WritableStream;
4+
use React\Stream\ThroughStream;
65

76
class FirstTest extends TestCase
87
{
98
public function testClosedReadableStreamRejects()
109
{
11-
$stream = new ReadableStream();
10+
$stream = new ThroughStream();
1211
$stream->close();
1312

1413
$promise = Stream\first($stream);
@@ -18,7 +17,7 @@ public function testClosedReadableStreamRejects()
1817

1918
public function testClosedWritableStreamRejects()
2019
{
21-
$stream = new WritableStream();
20+
$stream = new ThroughStream();
2221
$stream->close();
2322

2423
$promise = Stream\first($stream);
@@ -28,7 +27,7 @@ public function testClosedWritableStreamRejects()
2827

2928
public function testPendingStreamWillNotResolve()
3029
{
31-
$stream = new ReadableStream();
30+
$stream = new ThroughStream();
3231

3332
$promise = Stream\first($stream);
3433

@@ -37,7 +36,7 @@ public function testPendingStreamWillNotResolve()
3736

3837
public function testClosingStreamRejects()
3938
{
40-
$stream = new ReadableStream();
39+
$stream = new ThroughStream();
4140
$promise = Stream\first($stream);
4241

4342
$stream->close();
@@ -47,7 +46,7 @@ public function testClosingStreamRejects()
4746

4847
public function testClosingWritableStreamRejects()
4948
{
50-
$stream = new WritableStream();
49+
$stream = new ThroughStream();
5150
$promise = Stream\first($stream);
5251

5352
$stream->close();
@@ -57,7 +56,7 @@ public function testClosingWritableStreamRejects()
5756

5857
public function testClosingStreamResolvesWhenWaitingForCloseEvent()
5958
{
60-
$stream = new ReadableStream();
59+
$stream = new ThroughStream();
6160
$promise = Stream\first($stream, 'close');
6261

6362
$stream->close();
@@ -67,7 +66,7 @@ public function testClosingStreamResolvesWhenWaitingForCloseEvent()
6766

6867
public function testEmittingDataOnStreamResolvesWithFirstEvent()
6968
{
70-
$stream = new ReadableStream();
69+
$stream = new ThroughStream();
7170
$promise = Stream\first($stream);
7271

7372
$stream->emit('data', array('hello', $stream));
@@ -79,7 +78,7 @@ public function testEmittingDataOnStreamResolvesWithFirstEvent()
7978

8079
public function testEmittingErrorOnStreamDoesNothing()
8180
{
82-
$stream = new ReadableStream();
81+
$stream = new ThroughStream();
8382
$promise = Stream\first($stream);
8483

8584
$stream->emit('error', array(new \RuntimeException('test')));
@@ -89,7 +88,7 @@ public function testEmittingErrorOnStreamDoesNothing()
8988

9089
public function testEmittingErrorResolvesWhenWaitingForErrorEvent()
9190
{
92-
$stream = new ReadableStream();
91+
$stream = new ThroughStream();
9392
$promise = Stream\first($stream, 'error');
9493

9594
$stream->emit('error', array(new \RuntimeException('test')));
@@ -99,7 +98,7 @@ public function testEmittingErrorResolvesWhenWaitingForErrorEvent()
9998

10099
public function testCancelPendingStreamWillReject()
101100
{
102-
$stream = new ReadableStream();
101+
$stream = new ThroughStream();
103102

104103
$promise = Stream\first($stream);
105104

tests/UnwrapReadableTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
use React\Promise;
66
use React\Promise\Stream;
77
use React\Promise\Timer;
8-
use React\Stream\BufferedSink;
9-
use React\Stream\ReadableStream;
8+
use React\Stream\ThroughStream;
109

1110
class UnwrapReadableTest extends TestCase
1211
{
@@ -82,7 +81,7 @@ public function testEmitsErrorWhenPromiseResolvesWithWrongValue()
8281

8382
public function testReturnsClosedStreamIfInputStreamIsClosed()
8483
{
85-
$input = new ReadableStream();
84+
$input = new ThroughStream();
8685
$input->close();
8786

8887
$promise = Promise\resolve($input);
@@ -103,7 +102,7 @@ public function testReturnsClosedStreamIfInputHasWrongValue()
103102

104103
public function testReturnsStreamThatWillBeClosedWhenPromiseResolvesWithClosedInputStream()
105104
{
106-
$input = new ReadableStream();
105+
$input = new ThroughStream();
107106
$input->close();
108107

109108
$promise = Timer\resolve(0.001, $this->loop)->then(function () use ($input) {
@@ -123,7 +122,7 @@ public function testReturnsStreamThatWillBeClosedWhenPromiseResolvesWithClosedIn
123122

124123
public function testEmitsDataWhenInputEmitsData()
125124
{
126-
$input = new ReadableStream();
125+
$input = new ThroughStream();
127126

128127
$promise = Promise\resolve($input);
129128
$stream = Stream\unwrapReadable($promise);
@@ -134,7 +133,7 @@ public function testEmitsDataWhenInputEmitsData()
134133

135134
public function testEmitsErrorAndClosesWhenInputEmitsError()
136135
{
137-
$input = new ReadableStream();
136+
$input = new ThroughStream();
138137

139138
$promise = Promise\resolve($input);
140139
$stream = Stream\unwrapReadable($promise);
@@ -148,7 +147,7 @@ public function testEmitsErrorAndClosesWhenInputEmitsError()
148147

149148
public function testEmitsEndAndClosesWhenInputEmitsEnd()
150149
{
151-
$input = new ReadableStream();
150+
$input = new ThroughStream();
152151

153152
$promise = Promise\resolve($input);
154153
$stream = Stream\unwrapReadable($promise);
@@ -196,19 +195,20 @@ public function testForwardsResumeToInputStream()
196195

197196
public function testPipingStreamWillForwardDataEvents()
198197
{
199-
$input = new ReadableStream();
198+
$input = new ThroughStream();
200199

201200
$promise = Promise\resolve($input);
202201
$stream = Stream\unwrapReadable($promise);
203202

204-
$output = new BufferedSink();
203+
$output = new ThroughStream();
204+
$outputPromise = Stream\buffer($output);
205205
$stream->pipe($output);
206206

207207
$input->emit('data', array('hello'));
208208
$input->emit('data', array('world'));
209-
$input->close();
209+
$input->end();
210210

211-
$output->promise()->then($this->expectCallableOnceWith('helloworld'));
211+
$outputPromise->then($this->expectCallableOnceWith('helloworld'));
212212
}
213213

214214
public function testClosingStreamWillCloseInputStream()
@@ -225,7 +225,7 @@ public function testClosingStreamWillCloseInputStream()
225225

226226
public function testClosingStreamWillCloseStreamIfItIgnoredCancellationAndResolvesLater()
227227
{
228-
$input = new ReadableStream();
228+
$input = new ThroughStream();
229229

230230
$loop = $this->loop;
231231
$promise = new Promise\Promise(function ($resolve) use ($loop, $input) {
@@ -247,7 +247,7 @@ public function testClosingStreamWillCloseStreamIfItIgnoredCancellationAndResolv
247247

248248
public function testClosingStreamWillCloseStreamFromCancellationHandler()
249249
{
250-
$input = new ReadableStream();
250+
$input = new ThroughStream();
251251

252252
$promise = new \React\Promise\Promise(function () { }, function ($resolve) use ($input) {
253253
$resolve($input);

0 commit comments

Comments
 (0)