Skip to content

Commit 4d31573

Browse files
committed
Fxed promises in readable stream test
1 parent 1fad9c7 commit 4d31573

1 file changed

Lines changed: 9 additions & 48 deletions

File tree

tests/Stream/ReadableStreamTest.php

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,15 @@ public function testConstruct($className)
3030
$path = 'foo.bar';
3131
$fileDescriptor = '0123456789abcdef';
3232

33-
$promise = $this->getMock('React\Promise\PromiseInterface', [
34-
'then',
35-
]);
36-
37-
$promise
38-
->expects($this->once())
39-
->method('then')
40-
->with($this->isType('callable'))
41-
->will($this->returnCallback(function ($resolveCb) {
42-
$resolveCb([
43-
'size' => 123,
44-
]);
45-
}))
46-
;
47-
4833
$filesystem = $this->mockAdapter();
4934

5035
$filesystem
5136
->expects($this->once())
5237
->method('stat')
5338
->with($path)
54-
->will($this->returnValue($promise))
39+
->will($this->returnValue(\React\Promise\resolve([
40+
'size' => 123,
41+
])))
5542
;
5643

5744
$mock = $this->getMock($className, [
@@ -75,28 +62,15 @@ public function testResume($className)
7562
$path = 'foo.bar';
7663
$fileDescriptor = '0123456789abcdef';
7764

78-
$promise = $this->getMock('React\Promise\PromiseInterface', [
79-
'then',
80-
]);
81-
82-
$promise
83-
->expects($this->once())
84-
->method('then')
85-
->with($this->isType('callable'))
86-
->will($this->returnCallback(function ($resolveCb) {
87-
$resolveCb([
88-
'size' => 123,
89-
]);
90-
}))
91-
;
92-
9365
$filesystem = $this->mockAdapter();
9466

9567
$filesystem
9668
->expects($this->once())
9769
->method('stat')
9870
->with($path)
99-
->will($this->returnValue($promise))
71+
->will($this->returnValue(\React\Promise\resolve([
72+
'size' => 123,
73+
])))
10074
;
10175

10276
$mock = $this->getMock($className, [
@@ -245,21 +219,6 @@ public function testReadChunk($className, $stat)
245219
$path = 'foo.bar';
246220
$fileDescriptor = '0123456789abcdef';
247221

248-
$statPromise = $this->getMock('React\Promise\PromiseInterface', [
249-
'then',
250-
]);
251-
252-
$statPromise
253-
->expects($this->once())
254-
->method('then')
255-
->with($this->isType('callable'))
256-
->will($this->returnCallback(function ($resolveCb) {
257-
$resolveCb([
258-
'size' => 16384,
259-
]);
260-
}))
261-
;
262-
263222
$readPromise = $this->getMock('React\Promise\PromiseInterface', [
264223
'then',
265224
]);
@@ -279,7 +238,9 @@ public function testReadChunk($className, $stat)
279238
->expects($this->at((int)!$stat + 0))
280239
->method('stat')
281240
->with($path)
282-
->will($this->returnValue($statPromise))
241+
->will($this->returnValue(\React\Promise\resolve([
242+
'size' => 16384,
243+
])))
283244
;
284245

285246
$filesystem

0 commit comments

Comments
 (0)