Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/ObjectStreamSink.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class ObjectStreamSink
public static function promise(ObjectStream $stream)
{
$deferred = new Deferred();
$list = new \SplObjectStorage();
$list = array();

$stream->on('data', function ($object) use ($list) {
$list->attach($object);
$stream->on('data', function ($object) use (&$list) {
$list[] = $object;
});
$stream->on('end', function () use ($deferred, $list) {
$stream->on('end', function () use ($deferred, &$list) {
$deferred->resolve($list);
});

Expand Down
5 changes: 2 additions & 3 deletions tests/Adapters/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ public function testLs(LoopInterface $loop, FilesystemInterface $filesystem)
$path = $this->tmpDir . 'path';
touch($path);
$listing = $this->await($filesystem->dir($this->tmpDir)->ls(), $loop);
$listing->rewind();
$this->assertSame(1, $listing->count());
$this->assertSame($path, $listing->current()->getPath());
$this->assertSame(1, count($listing));
$this->assertSame($path, reset($listing)->getPath());
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/ChildProcess/AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,8 @@ public function testLs()
]);

$nodes = $this->await($promise, $loop);
$nodes->rewind();

$this->assertEquals(new File('foo.bar/bar.foo', $fs), $nodes->current());
$this->assertEquals(new File('foo.bar/bar.foo', $fs), reset($nodes));
}

public function testLsStream()
Expand Down
9 changes: 5 additions & 4 deletions tests/ObjectStreamSinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ public function testSink()
$this->assertInstanceOf('React\Promise\PromiseInterface', $sink);
$stream->emit('data', [$node]);
$stream->close();

$nodes = null;
$sink->then(function (\SplObjectStorage $list) use (&$nodes) {
$sink->then(function ($list) use (&$nodes) {
$nodes = $list;
});
$nodes->rewind();
$this->assertSame(1, $nodes->count());
$this->assertSame($node, $nodes->current());

$this->assertSame(1, count($nodes));
$this->assertSame($node, reset($nodes));
}
}