diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-02 16:16:06 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:31 +0200 |
commit | 3e3226da4c6bb120f16e58f07c2f8c6ad17a2350 (patch) | |
tree | 0529a88e4b7e37d035c1cf37d5a5bc067cb795d6 /tests | |
parent | a7e71513644a2e1a3ec632eb8d93f6affcee6cca (diff) | |
download | nextcloud-server-3e3226da4c6bb120f16e58f07c2f8c6ad17a2350.tar.gz nextcloud-server-3e3226da4c6bb120f16e58f07c2f8c6ad17a2350.zip |
Properly set size and unencrypted size in the stream unit tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/stream/encryption.php | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/lib/files/stream/encryption.php b/tests/lib/files/stream/encryption.php index c7e7f0ddf95..3e30385dfef 100644 --- a/tests/lib/files/stream/encryption.php +++ b/tests/lib/files/stream/encryption.php @@ -11,8 +11,9 @@ class Encryption extends \Test\TestCase { * @param string $mode * @param integer $limit */ - protected function getStream($fileName, $mode) { + protected function getStream($fileName, $mode, $unencryptedSize) { + $size = filesize($fileName); $source = fopen($fileName, $mode); $internalPath = $fileName; $fullPath = $fileName; @@ -33,8 +34,6 @@ class Encryption extends \Test\TestCase { $util->expects($this->any()) ->method('getUidAndFilename') ->willReturn(['user1', $internalPath]); - $size = 12; - $unencryptedSize = 8000; return \OC\Files\Stream\Encryption::wrap($source, $internalPath, $fullPath, $header, $uid, $encryptionModule, $storage, $encStorage, @@ -43,24 +42,24 @@ class Encryption extends \Test\TestCase { public function testWriteRead() { $fileName = tempnam("/tmp", "FOO"); - $stream = $this->getStream($fileName, 'w+'); + $stream = $this->getStream($fileName, 'w+', 0); $this->assertEquals(6, fwrite($stream, 'foobar')); fclose($stream); - $stream = $this->getStream($fileName, 'r'); + $stream = $this->getStream($fileName, 'r', 6); $this->assertEquals('foobar', fread($stream, 100)); fclose($stream); } public function testSeek() { $fileName = tempnam("/tmp", "FOO"); - $stream = $this->getStream($fileName, 'w+'); + $stream = $this->getStream($fileName, 'w+', 0); $this->assertEquals(6, fwrite($stream, 'foobar')); $this->assertEquals(0, fseek($stream, 3)); $this->assertEquals(6, fwrite($stream, 'foobar')); fclose($stream); - $stream = $this->getStream($fileName, 'r'); + $stream = $this->getStream($fileName, 'r', 9); $this->assertEquals('foofoobar', fread($stream, 100)); fclose($stream); } @@ -69,12 +68,12 @@ class Encryption extends \Test\TestCase { $expectedData = file_get_contents(\OC::$SERVERROOT . '/tests/data/lorem-big.txt'); // write it $fileName = tempnam("/tmp", "FOO"); - $stream = $this->getStream($fileName, 'w+'); + $stream = $this->getStream($fileName, 'w+', 0); fwrite($stream, $expectedData); fclose($stream); // read it all - $stream = $this->getStream($fileName, 'r'); + $stream = $this->getStream($fileName, 'r', strlen($expectedData)); $data = stream_get_contents($stream); fclose($stream); |