public function testWaterfallWithError() { $called = 0; $tasks = array(function ($callback, $errback) use(&$called) { $callback('foo'); $called++; }, function ($foo, $callback, $errback) { $e = new \RuntimeException('whoops'); $errback($e); }, function ($callback, $errback) use(&$called) { $callback('bar'); $called++; }); $callback = $this->createCallableMock($this->never()); $errback = $this->createCallableMock($this->once()); Util::waterfall($tasks, $callback, $errback); $this->assertSame(1, $called); }
public function testParallelWithDelayedError() { $called = 0; $loop = new \React\EventLoop\StreamSelectLoop(); $tasks = array(function ($callback, $errback) use(&$called) { $callback('foo'); $called++; }, function ($callback, $errback) use($loop) { $loop->addTimer(0.001, function () use($errback) { $e = new \RuntimeException('whoops'); $errback($e); }); }, function ($callback, $errback) use(&$called) { $callback('bar'); $called++; }); $callback = $this->createCallableMock($this->never()); $errback = $this->createCallableMock($this->once()); Util::parallel($tasks, $callback, $errback); $loop->run(); $this->assertSame(2, $called); }