/** @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);
 }
Beispiel #3
0
 public function testClosedWritableStreamResolvesWithEmptyBuffer()
 {
     $stream = new WritableStream();
     $stream->close();
     $promise = Stream\all($stream);
     $this->expectPromiseResolveWith(array(), $promise);
 }
Beispiel #4
0
 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 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());
 }