public function testSeekTell() { $s = new Stream(); $s->open(STREAM_MODE_READWRITE); $this->assertEquals($s->tell(), 0, 'wrong start position'); $this->assertEquals($s->size(), 0, 'wrong initial size'); $s->writeLine('Foo Bar Baz'); $this->assertEquals($s->tell(), 12, 'wrong position'); $this->assertEquals($s->size(), 12, 'wrong size'); }
public function testReadline() { $stream = new Stream(); $stream->open(STREAM_MODE_WRITE); $stream->writeLine('This is the first line.'); $stream->writeLine('This is the second line.'); $stream->writeLine('And there is a third one.'); $stream->close(); $stream->open(STREAM_MODE_READ); $this->s = new EncapsedStream($stream, 5, $stream->size() - 35); $this->assertEquals('is the first line.', $this->s->readLine()); $this->assertEquals('This is the second li', $this->s->readLine()); $this->assertEquals('', $this->s->readLine()); }