public function testAllowsBoundedSeek() { $this->body->seek(100); $this->assertEquals(10, $this->body->tell()); $this->assertEquals(13, $this->decorated->tell()); $this->body->seek(0); $this->assertEquals(0, $this->body->tell()); $this->assertEquals(3, $this->decorated->tell()); try { $this->body->seek(-10); $this->fail(); } catch (RuntimeException $e) { } $this->assertEquals(0, $this->body->tell()); $this->assertEquals(3, $this->decorated->tell()); $this->body->seek(5); $this->assertEquals(5, $this->body->tell()); $this->assertEquals(8, $this->decorated->tell()); // Fail try { $this->body->seek(1000, SEEK_END); $this->fail(); } catch (RuntimeException $e) { } }
public function testProvidesStreamPosition() { $handle = fopen('php://temp', 'w+'); $stream = new Stream($handle); $this->assertEquals(0, $stream->tell()); $stream->write('foo'); $this->assertEquals(3, $stream->tell()); $stream->seek(1); $this->assertEquals(1, $stream->tell()); $this->assertSame(ftell($handle), $stream->tell()); $stream->close(); }