Commit 7a34f75d authored by jknockaert's avatar jknockaert Committed by Bjoern Schiessle
Browse files

add two tests

testRewind tests reading and writing after rewind on an encrypted stream; testWriteWriteRead tests r+ mode
parent 17565625
......@@ -152,6 +152,36 @@ class Encryption extends \Test\TestCase {
unlink($fileName);
}
public function testWriteWriteRead() {
$fileName = tempnam("/tmp", "FOO");
$stream = $this->getStream($fileName, 'w+', 0);
$this->assertEquals(6, fwrite($stream, 'foobar'));
fclose($stream);
$stream = $this->getStream($fileName, 'r+', 6);
$this->assertEquals(3, fwrite($stream, 'bar'));
fclose($stream);
$stream = $this->getStream($fileName, 'r', 6);
$this->assertEquals('barbar', fread($stream, 100));
fclose($stream);
}
public function testRewind() {
$fileName = tempnam("/tmp", "FOO");
$stream = $this->getStream($fileName, 'w+', 0);
$this->assertEquals(6, fwrite($stream, 'foobar'));
$this->assertEquals(TRUE, rewind($stream));
$this->assertEquals('foobar', fread($stream, 100));
$this->assertEquals(TRUE, rewind($stream));
$this->assertEquals(3, fwrite($stream, 'bar'));
fclose($stream);
$stream = $this->getStream($fileName, 'r', 6);
$this->assertEquals('barbar', fread($stream, 100));
fclose($stream);
}
public function testSeek() {
$fileName = tempnam("/tmp", "FOO");
$stream = $this->getStream($fileName, 'w+', 0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment