diff options
author | jknockaert <jasper@knockaert.nl> | 2015-04-21 17:36:25 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-04-24 16:44:00 +0200 |
commit | 7a34f75da6081dfc6d85c2498b1a68838c28fb18 (patch) | |
tree | afe7de9e96627956f89e4813ec18559dbcee3be2 /tests/lib/files/stream | |
parent | 1756562501e3201ed21a6f8a26b53c6bfdf12934 (diff) | |
download | nextcloud-server-7a34f75da6081dfc6d85c2498b1a68838c28fb18.tar.gz nextcloud-server-7a34f75da6081dfc6d85c2498b1a68838c28fb18.zip |
add two tests
testRewind tests reading and writing after rewind on an encrypted stream; testWriteWriteRead tests r+ mode
Diffstat (limited to 'tests/lib/files/stream')
-rw-r--r-- | tests/lib/files/stream/encryption.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lib/files/stream/encryption.php b/tests/lib/files/stream/encryption.php index 1da208282e6..024185b34c8 100644 --- a/tests/lib/files/stream/encryption.php +++ b/tests/lib/files/stream/encryption.php @@ -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); |