|
5 | 5 | use React\EventLoop\Factory;
|
6 | 6 | use React\Filesystem\ChildProcess\Adapter;
|
7 | 7 | use React\Filesystem\Filesystem;
|
| 8 | +use React\Filesystem\Node\File; |
8 | 9 | use React\Filesystem\Node\NodeInterface;
|
9 | 10 | use React\Promise\Deferred;
|
10 | 11 | use React\Promise\FulfilledPromise;
|
@@ -278,6 +279,52 @@ public function testSymlink()
|
278 | 279 | }
|
279 | 280 |
|
280 | 281 | public function testLs()
|
| 282 | + { |
| 283 | + $loop = \React\EventLoop\Factory::create(); |
| 284 | + $adapter = new Adapter($loop, [ |
| 285 | + 'pool' => [ |
| 286 | + 'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy', |
| 287 | + ], |
| 288 | + ]); |
| 289 | + $invoker = $this->getMock('React\Filesystem\CallInvokerInterface', [ |
| 290 | + '__construct', |
| 291 | + 'invokeCall', |
| 292 | + 'isEmpty', |
| 293 | + ]); |
| 294 | + $adapter->setInvoker($invoker); |
| 295 | + $fs = Filesystem::createFromAdapter($adapter); |
| 296 | + |
| 297 | + $deferred = new Deferred(); |
| 298 | + |
| 299 | + $invoker |
| 300 | + ->expects($this->once()) |
| 301 | + ->method('invokeCall') |
| 302 | + ->with( |
| 303 | + 'readdir', |
| 304 | + [ |
| 305 | + 'path' => 'foo.bar', |
| 306 | + 'flags' => 2, |
| 307 | + ] |
| 308 | + )->will($this->returnValue($deferred->promise())) |
| 309 | + ; |
| 310 | + |
| 311 | + $promise = $adapter->ls('foo.bar'); |
| 312 | + $this->assertInstanceOf('React\Promise\PromiseInterface', $promise); |
| 313 | + |
| 314 | + $deferred->resolve([ |
| 315 | + [ |
| 316 | + 'type' => 'file', |
| 317 | + 'name' => 'bar.foo', |
| 318 | + ], |
| 319 | + ]); |
| 320 | + |
| 321 | + $nodes = $this->await($promise, $loop); |
| 322 | + $nodes->rewind(); |
| 323 | + |
| 324 | + $this->assertEquals(new File('foo.bar/bar.foo', $fs), $nodes->current()); |
| 325 | + } |
| 326 | + |
| 327 | + public function testLsStream() |
281 | 328 | {
|
282 | 329 | $loop = $this->getMock('React\EventLoop\LoopInterface');
|
283 | 330 | $adapter = new Adapter($loop, [
|
@@ -307,7 +354,7 @@ public function testLs()
|
307 | 354 | )->will($this->returnValue($deferred->promise()))
|
308 | 355 | ;
|
309 | 356 |
|
310 |
| - $stream = $adapter->ls('foo.bar'); |
| 357 | + $stream = $adapter->lsStream('foo.bar'); |
311 | 358 | $this->assertInstanceOf('React\Filesystem\ObjectStream', $stream);
|
312 | 359 |
|
313 | 360 | $calledOnData = false;
|
|
0 commit comments