]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix unit tests
authorRobin Appelman <icewind@owncloud.com>
Tue, 3 Jun 2014 09:34:48 +0000 (11:34 +0200)
committerRobin Appelman <icewind@owncloud.com>
Tue, 3 Jun 2014 09:55:18 +0000 (11:55 +0200)
tests/lib/files/utils/scanner.php
tests/lib/files/view.php

index 4610e2b4d46f6661c4ac0f220486d882e10e53fe..267fc63302dad35846f4ac683d07c8b2b27d9862 100644 (file)
@@ -42,6 +42,7 @@ class Scanner extends \PHPUnit_Framework_TestCase {
        public function testReuseExistingRoot() {
                $storage = new Temporary(array());
                $mount = new Mount($storage, '');
+               Filesystem::getMountManager()->addMount($mount);
                $cache = $storage->getCache();
 
                $storage->mkdir('folder');
@@ -63,6 +64,7 @@ class Scanner extends \PHPUnit_Framework_TestCase {
        public function testReuseExistingFile() {
                $storage = new Temporary(array());
                $mount = new Mount($storage, '');
+               Filesystem::getMountManager()->addMount($mount);
                $cache = $storage->getCache();
 
                $storage->mkdir('folder');
index b5e4d79235095a9e9558a81a9c3c8fea2f8df025..1d8e729fb7b53baf29909951a6d265b9aa201d42 100644 (file)
@@ -52,14 +52,18 @@ class View extends \PHPUnit_Framework_TestCase {
                $storage1 = $this->getTestStorage();
                $storage2 = $this->getTestStorage();
                $storage3 = $this->getTestStorage();
-               \OC\Files\Filesystem::mount($storage1, array(), '/');
-               \OC\Files\Filesystem::mount($storage2, array(), '/substorage');
-               \OC\Files\Filesystem::mount($storage3, array(), '/folder/anotherstorage');
+               $root = '/' . uniqid();
+               \OC\Files\Filesystem::mount($storage1, array(), $root . '/');
+               \OC\Files\Filesystem::mount($storage2, array(), $root . '/substorage');
+               \OC\Files\Filesystem::mount($storage3, array(), $root . '/folder/anotherstorage');
                $textSize = strlen("dummy file data\n");
                $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png');
                $storageSize = $textSize * 2 + $imageSize;
 
-               $rootView = new \OC\Files\View('');
+               $storageInfo = $storage3->getCache()->get('');
+               $this->assertEquals($storageSize, $storageInfo['size']);
+
+               $rootView = new \OC\Files\View($root);
 
                $cachedData = $rootView->getFileInfo('/foo.txt');
                $this->assertEquals($textSize, $cachedData['size']);
@@ -110,7 +114,7 @@ class View extends \PHPUnit_Framework_TestCase {
                $this->assertEquals('foo.png', $folderData[1]['name']);
                $this->assertEquals('foo.txt', $folderData[2]['name']);
 
-               $folderView = new \OC\Files\View('/folder');
+               $folderView = new \OC\Files\View($root . '/folder');
                $this->assertEquals($rootView->getFileInfo('/folder'), $folderView->getFileInfo('/'));
 
                $cachedData = $rootView->getFileInfo('/foo.txt');
@@ -580,9 +584,9 @@ class View extends \PHPUnit_Framework_TestCase {
                $longPath = '';
                // 4000 is the maximum path length in file_cache.path
                $folderName = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123456789';
-               $depth = (4000/57);
-               foreach (range(0, $depth-1) as $i) {
-                       $longPath .= '/'.$folderName;
+               $depth = (4000 / 57);
+               foreach (range(0, $depth - 1) as $i) {
+                       $longPath .= '/' . $folderName;
                        $result = $rootView->mkdir($longPath);
                        $this->assertTrue($result, "mkdir failed on $i - path length: " . strlen($longPath));
 
@@ -598,7 +602,7 @@ class View extends \PHPUnit_Framework_TestCase {
                $scanner->scan('');
 
                $longPath = $folderName;
-               foreach (range(0, $depth-1) as $i) {
+               foreach (range(0, $depth - 1) as $i) {
                        $cachedFolder = $cache->get($longPath);
                        $this->assertTrue(is_array($cachedFolder), "No cache entry for folder at $i");
                        $this->assertEquals($folderName, $cachedFolder['name'], "Wrong cache entry for folder at $i");
@@ -652,14 +656,14 @@ class View extends \PHPUnit_Framework_TestCase {
         * @dataProvider tooLongPathDataProvider
         * @expectedException \OCP\Files\InvalidPathException
         */
-       public function testTooLongPath($operation, $param0 = NULL) {
+       public function testTooLongPath($operation, $param0 = null) {
 
                $longPath = '';
                // 4000 is the maximum path length in file_cache.path
                $folderName = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123456789';
-               $depth = (4000/57);
-               foreach (range(0, $depth+1) as $i) {
-                       $longPath .= '/'.$folderName;
+               $depth = (4000 / 57);
+               foreach (range(0, $depth + 1) as $i) {
+                       $longPath .= '/' . $folderName;
                }
 
                $storage = new \OC\Files\Storage\Temporary(array());