public function create($host, $port)
 {
     $connectionManager = $this->connectionManager;
     return Timer\resolve($this->delay, $this->loop)->then(function () use($connectionManager, $host, $port) {
         return $connectionManager->create($host, $port);
     });
 }
 public function testReturnsStreamThatWillBeClosedWhenPromiseResolvesWithClosedInputStream()
 {
     $input = new ReadableStream();
     $input->close();
     $promise = Timer\resolve(0.001, $this->loop)->then(function () use($input) {
         return $input;
     });
     $stream = Stream\unwrapReadable($promise);
     $this->assertTrue($stream->isReadable());
     $stream->on('close', $this->expectCallableOnce());
     $this->loop->run();
     $this->assertFalse($stream->isReadable());
 }
 public function testForwardsNoDataWhenWritingAfterEndOncePromiseResolves()
 {
     $input = $this->getMock('React\\Stream\\WritableStreamInterface');
     $input->expects($this->once())->method('isWritable')->willReturn(true);
     $input->expects($this->never())->method('write');
     $input->expects($this->once())->method('end');
     $promise = Timer\resolve(0.001, $this->loop)->then(function () use($input) {
         return $input;
     });
     $stream = Stream\unwrapWritable($promise);
     $stream->end();
     $stream->write('nope');
     $this->loop->run();
 }
예제 #4
0
 public function testCancelingPromiseWillRejectTimer()
 {
     $promise = Timer\resolve(0.01, $this->loop);
     $promise->cancel();
     $this->expectPromiseRejected($promise);
 }
예제 #5
0
/**
 * wait/sleep for $time seconds
 *
 * @param float $time
 * @param LoopInterface $loop
 */
function sleep($time, LoopInterface $loop)
{
    await(Timer\resolve($time, $loop), $loop);
}