Skip to content

Commit 3bc2c27

Browse files
authored
Merge pull request #13 from clue-labs/all-args
Fix `all()` to assume null values if no event data is passed
2 parents 3c9018d + 04a8528 commit 3bc2c27

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function all(EventEmitterInterface $stream, $event = 'data')
125125
}
126126

127127
$buffer = array();
128-
$bufferer = function ($data) use (&$buffer) {
128+
$bufferer = function ($data = null) use (&$buffer) {
129129
$buffer []= $data;
130130
};
131131
$stream->on($event, $bufferer);

tests/AllTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ public function testEmittingDataOnStreamResolvesWithArrayOfData()
6868
$this->expectPromiseResolveWith(array('hello', 'world'), $promise);
6969
}
7070

71+
public function testEmittingCustomEventOnStreamResolvesWithArrayOfCustomEventData()
72+
{
73+
$stream = new ThroughStream();
74+
$promise = Stream\all($stream, 'a');
75+
76+
$stream->emit('a', array('hello'));
77+
$stream->emit('b', array('ignored'));
78+
$stream->emit('a');
79+
$stream->close();
80+
81+
$this->expectPromiseResolveWith(array('hello', null), $promise);
82+
}
83+
7184
public function testEmittingErrorOnStreamRejects()
7285
{
7386
$stream = new ThroughStream();

0 commit comments

Comments
 (0)