/** @test */ public function doubleCloseShouldWork() { $through = new WritableStream(); $through->close(); $through->close(); $this->assertFalse($through->isWritable()); }
public function testClosedWritableStreamRejects() { $stream = new WritableStream(); $stream->close(); $promise = Stream\first($stream); $this->expectPromiseReject($promise); }
public function testClosedWritableStreamResolvesWithEmptyBuffer() { $stream = new WritableStream(); $stream->close(); $promise = Stream\all($stream); $this->expectPromiseResolveWith(array(), $promise); }
/** @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'); }
/** @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()); }
public function close() { if ($this->closed) { return; } parent::close(); $this->deferred->resolve($this->buffer); }
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); }
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())); }