示例#1
0
 /** @test */
 public function doubleCloseShouldWork()
 {
     $through = new WritableStream();
     $through->close();
     $through->close();
     $this->assertFalse($through->isWritable());
 }
示例#2
0
 public function testClosedWritableStreamRejects()
 {
     $stream = new WritableStream();
     $stream->close();
     $promise = Stream\first($stream);
     $this->expectPromiseReject($promise);
 }
示例#3
0
 public function testClosedWritableStreamResolvesWithEmptyBuffer()
 {
     $stream = new WritableStream();
     $stream->close();
     $promise = Stream\all($stream);
     $this->expectPromiseResolveWith(array(), $promise);
 }
示例#4
0
 /** @test */
 public function itShouldReceiveForwardedEvents()
 {
     $readable = new ReadableStream();
     $writable = new WritableStream();
     $composite = new CompositeStream($readable, $writable);
     $composite->on('data', $this->expectCallableOnce());
     $composite->on('drain', $this->expectCallableOnce());
     $readable->emit('data', array('foo'));
     $writable->emit('drain');
 }
示例#5
0
 /** @test */
 public function itShouldReceiveForwardedEvents()
 {
     $readable = new ReadableStream();
     $writable = new WritableStream();
     $composite = new CompositeStream($readable, $writable);
     $composite->on(Event::DATA, $this->expectCallableOnce());
     $composite->on(Event::DRAIN, $this->expectCallableOnce());
     $readable->emit(Event::DATA, array('foo'));
     $writable->emit(Event::DRAIN);
 }
 public function testReturnsStreamThatWillBeClosedWhenPromiseResolvesWithClosedInputStream()
 {
     $input = new WritableStream();
     $input->close();
     $promise = Timer\resolve(0.001, $this->loop)->then(function () use($input) {
         return $input;
     });
     $stream = Stream\unwrapWritable($promise);
     $this->assertTrue($stream->isWritable());
     $stream->on('close', $this->expectCallableOnce());
     $this->loop->run();
     $this->assertFalse($stream->isWritable());
 }
示例#7
0
 public function close()
 {
     if ($this->closed) {
         return;
     }
     parent::close();
     $this->deferred->resolve($this->buffer);
 }
示例#8
0
 public function close()
 {
     if ($this->closed) {
         return;
     }
     parent::close();
     $this->client->end();
 }
 public function testPipeWillBeForwardedToTargetStream()
 {
     $target = new WritableStream();
     $target->on('pipe', $this->expectCallableOnceWith($this->parser));
     $this->parser->pipe($target);
 }
示例#10
0
 public function testErrorEventFromOutputWillBeForwarded()
 {
     $input = $this->getMock('React\\Stream\\ReadableStreamInterface');
     $output = new WritableStream();
     //$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
     $readline = new Readline($input, $output);
     $stdio = new Stdio($this->loop, $input, $output, $readline);
     $stdio->on('error', $this->expectCallableOnce());
     $output->emit('error', array(new \RuntimeException()));
 }