public function testGetsContents() { $handle = fopen('php://temp', 'w+'); fwrite($handle, 'data'); $stream = new Stream($handle); $this->assertEquals('', $stream->getContents()); $stream->seek(0); $this->assertEquals('data', $stream->getContents()); $this->assertEquals('', $stream->getContents()); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Could not seek to stream offset 2 */ public function testThrowsWhenCurrentGreaterThanOffsetSeek() { $body = 'foo_bar'; $stream = fopen('php://temp', 'r+'); fwrite($stream, $body); fseek($stream, 0); $stream1 = new Stream($stream); $stream2 = new NoSeekStream($stream1); $stream3 = new LimitStream($stream2); $stream1->getContents(); $stream3->setOffset(2); }