public function of_with_io_element() { $e = newinstance('io.collections.IOElement', array(new MemoryInputStream('Test')), '{ protected $stream; public function __construct($stream) { $this->stream= $stream; } public function getURI() { return "/path/to/test.txt"; } public function getSize() { return 6100; } public function createdAt() { return NULL; } public function lastAccessed() { return NULL; } public function lastModified() { return new Date("2013-03-26 10:53:00"); } public function getOrigin() { return NULL; } public function setOrigin(IOCollection $origin) { } public function getInputStream() { return $this->stream; } public function getOutputStream() { return NULL; } }'); $this->assertEquals(create(new StreamingOutput($e->getInputStream()))->withMediaType('text/plain')->withContentLength(6100)->withLastModified(new Date('2013-03-26 10:53:00')), StreamingOutput::of($e)); }
public function download_greeting() { $s = StreamingOutput::of(new MemoryInputStream('Hello World'))->withMediaType('text/plain; charset=utf-8')->withContentLength(11)->withStatus(200); $s->buffered = TRUE; // For easier testability! return $s; }