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()); } }
/** * @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); }