/** @test */
 public function pipingStuffIntoItShouldWorkButDoNothing()
 {
     $readable = new ReadableStream();
     $through = new WritableStream();
     $readable->pipe($through);
     $readable->emit(Event::DATA, array('foo'));
 }
 /** @test */
 public function pipingStuffIntoItShouldWork()
 {
     $readable = new ReadableStream();
     $through = new ThroughStream();
     $through->on('data', $this->expectCallableOnceWith('foo'));
     $readable->pipe($through);
     $readable->emit('data', array('foo'));
 }
 /** @test */
 public function itShouldHandlePipingCorrectly()
 {
     $readable = $this->getMock('React\\Stream\\ReadableStreamInterface');
     $writable = $this->getMock('React\\Stream\\WritableStreamInterface');
     $writable->expects($this->once())->method('write')->with('foo');
     $composite = new CompositeStream($readable, $writable);
     $input = new ReadableStream();
     $input->pipe($composite);
     $input->emit('data', array('foo'));
 }
 /** @test */
 public function pipeShouldSucceedAndResolve()
 {
     $callback = $this->expectCallableOnceWith('foobar');
     $sink = new BufferedSink();
     $sink->promise()->then($callback);
     $readable = new ReadableStream();
     $readable->pipe($sink);
     $readable->emit(Event::DATA, array('foo'));
     $readable->emit(Event::DATA, array('bar'));
     $readable->close();
 }
Exemple #5
0
 public static function createPromise(ReadableStream $stream)
 {
     $sink = new static();
     $stream->pipe($sink);
     return $sink->promise();
 }