3
3
namespace React \Tests \Stream ;
4
4
5
5
use React \Stream \CompositeStream ;
6
+ use React \Stream \ReadableStreamInterface ;
6
7
use React \Stream \ThroughStream ;
8
+ use React \Stream \WritableStreamInterface ;
7
9
8
10
/**
9
11
* @covers React\Stream\CompositeStream
@@ -13,7 +15,7 @@ class CompositeStreamTest extends TestCase
13
15
/** @test */
14
16
public function itShouldCloseReadableIfNotWritable ()
15
17
{
16
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
18
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
17
19
$ readable
18
20
->expects ($ this ->once ())
19
21
->method ('isReadable ' )
@@ -22,7 +24,7 @@ public function itShouldCloseReadableIfNotWritable()
22
24
->expects ($ this ->once ())
23
25
->method ('close ' );
24
26
25
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
27
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
26
28
$ writable
27
29
->expects ($ this ->once ())
28
30
->method ('isWritable ' )
@@ -37,13 +39,13 @@ public function itShouldCloseReadableIfNotWritable()
37
39
/** @test */
38
40
public function itShouldCloseWritableIfNotReadable ()
39
41
{
40
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
42
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
41
43
$ readable
42
44
->expects ($ this ->once ())
43
45
->method ('isReadable ' )
44
46
->willReturn (false );
45
47
46
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
48
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
47
49
$ writable
48
50
->expects ($ this ->once ())
49
51
->method ('close ' );
@@ -57,13 +59,13 @@ public function itShouldCloseWritableIfNotReadable()
57
59
/** @test */
58
60
public function itShouldForwardWritableCallsToWritableStream ()
59
61
{
60
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
62
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
61
63
$ readable
62
64
->expects ($ this ->once ())
63
65
->method ('isReadable ' )
64
66
->willReturn (true );
65
67
66
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
68
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
67
69
$ writable
68
70
->expects ($ this ->once ())
69
71
->method ('write ' )
@@ -81,7 +83,7 @@ public function itShouldForwardWritableCallsToWritableStream()
81
83
/** @test */
82
84
public function itShouldForwardReadableCallsToReadableStream ()
83
85
{
84
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
86
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
85
87
$ readable
86
88
->expects ($ this ->exactly (2 ))
87
89
->method ('isReadable ' )
@@ -93,7 +95,7 @@ public function itShouldForwardReadableCallsToReadableStream()
93
95
->expects ($ this ->once ())
94
96
->method ('resume ' );
95
97
96
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
98
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
97
99
$ writable
98
100
->expects ($ this ->any ())
99
101
->method ('isWritable ' )
@@ -108,7 +110,7 @@ public function itShouldForwardReadableCallsToReadableStream()
108
110
/** @test */
109
111
public function itShouldNotForwardResumeIfStreamIsNotWritable ()
110
112
{
111
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
113
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
112
114
$ readable
113
115
->expects ($ this ->once ())
114
116
->method ('isReadable ' )
@@ -117,7 +119,7 @@ public function itShouldNotForwardResumeIfStreamIsNotWritable()
117
119
->expects ($ this ->never ())
118
120
->method ('resume ' );
119
121
120
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
122
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
121
123
$ writable
122
124
->expects ($ this ->exactly (2 ))
123
125
->method ('isWritable ' )
@@ -130,13 +132,13 @@ public function itShouldNotForwardResumeIfStreamIsNotWritable()
130
132
/** @test */
131
133
public function endShouldDelegateToWritableWithData ()
132
134
{
133
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
135
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
134
136
$ readable
135
137
->expects ($ this ->once ())
136
138
->method ('isReadable ' )
137
139
->willReturn (true );
138
140
139
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
141
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
140
142
$ writable
141
143
->expects ($ this ->once ())
142
144
->method ('isWritable ' )
@@ -153,7 +155,7 @@ public function endShouldDelegateToWritableWithData()
153
155
/** @test */
154
156
public function closeShouldCloseBothStreams ()
155
157
{
156
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
158
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
157
159
$ readable
158
160
->expects ($ this ->once ())
159
161
->method ('isReadable ' )
@@ -162,7 +164,7 @@ public function closeShouldCloseBothStreams()
162
164
->expects ($ this ->once ())
163
165
->method ('close ' );
164
166
165
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
167
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
166
168
$ writable
167
169
->expects ($ this ->once ())
168
170
->method ('isWritable ' )
@@ -224,13 +226,13 @@ public function itShouldReceiveForwardedEvents()
224
226
/** @test */
225
227
public function itShouldHandlePipingCorrectly ()
226
228
{
227
- $ readable = $ this ->getMockBuilder ( ' React\Stream\ ReadableStreamInterface' )-> getMock ( );
229
+ $ readable = $ this ->createMock ( ReadableStreamInterface::class );
228
230
$ readable
229
231
->expects ($ this ->once ())
230
232
->method ('isReadable ' )
231
233
->willReturn (true );
232
234
233
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
235
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
234
236
$ writable ->expects ($ this ->any ())->method ('isWritable ' )->willReturn (True );
235
237
$ writable
236
238
->expects ($ this ->once ())
@@ -249,12 +251,12 @@ public function itShouldForwardPipeCallsToReadableStream()
249
251
{
250
252
$ readable = new ThroughStream ();
251
253
252
- $ writable = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
254
+ $ writable = $ this ->createMock ( WritableStreamInterface::class );
253
255
$ writable ->expects ($ this ->any ())->method ('isWritable ' )->willReturn (True );
254
256
255
257
$ composite = new CompositeStream ($ readable , $ writable );
256
258
257
- $ output = $ this ->getMockBuilder ( ' React\Stream\ WritableStreamInterface' )-> getMock ( );
259
+ $ output = $ this ->createMock ( WritableStreamInterface::class );
258
260
$ output ->expects ($ this ->any ())->method ('isWritable ' )->willReturn (True );
259
261
$ output
260
262
->expects ($ this ->once ())
0 commit comments