Ejemplo n.º 1
0
 public function testCloseAndException()
 {
     $stream = new Stream('php://memory', 'w+');
     $stream->close();
     $stream->close();
     $this->assertFalse($stream->isWritable());
     $this->assertFalse($stream->isReadable());
     $this->assertFalse($stream->isSeekable());
     $this->assertSame('', $stream->__toString());
     $this->assertNull($stream->getSize());
     $this->assertTrue($stream->eof());
     try {
         $stream->write('...?');
         $this->fail();
     } catch (RuntimeException $e) {
         $this->assertEquals('No resource available.', $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * @param int $statusCode
  * @param string $message
  * @param array $headers
  * @return BaseResponse
  */
 public static function factory($statusCode, $message, $headers = [])
 {
     $body = new Stream('php://memory', 'r+');
     $body->write($message);
     return new BaseResponse($statusCode, '', $headers, $body);
 }