/**
  * test seeking to offset
  *
  * @test
  */
 public function seekRead()
 {
     $this->file->setContent('foobarbaz');
     $this->assertFalse($this->file->seek(0, 55));
     $this->assertTrue($this->file->seek(0, SEEK_SET));
     $this->assertEquals('foobarbaz', $this->file->readUntilEnd());
     $this->assertEquals(0, $this->file->getBytesRead());
     $this->assertTrue($this->file->seek(5, SEEK_SET));
     $this->assertEquals('rbaz', $this->file->readUntilEnd());
     $this->assertEquals(5, $this->file->getBytesRead());
     $this->assertTrue($this->file->seek(0, SEEK_CUR));
     $this->assertEquals('rbaz', $this->file->readUntilEnd());
     $this->assertEquals(5, $this->file->getBytesRead(), 5);
     $this->assertTrue($this->file->seek(2, SEEK_CUR));
     $this->assertEquals('az', $this->file->readUntilEnd());
     $this->assertEquals(7, $this->file->getBytesRead());
     $this->assertTrue($this->file->seek(0, SEEK_END));
     $this->assertEquals('', $this->file->readUntilEnd());
     $this->assertEquals(9, $this->file->getBytesRead());
     $this->assertTrue($this->file->seek(2, SEEK_END));
     $this->assertEquals('', $this->file->readUntilEnd());
     $this->assertEquals(11, $this->file->getBytesRead());
 }
Exemple #2
0
 /**
  * returns the current position of the stream
  *
  * @return  int
  */
 public function stream_tell()
 {
     return $this->content->getBytesRead();
 }