diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-12-12 16:32:12 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-12-12 16:32:12 +0100 |
commit | db946256f9949e20b95fd07daa95cb2e5f51fa2e (patch) | |
tree | b528d208597cab98276a61b9e8e3d088713a166e | |
parent | eb92c9bd1ba65b840f51c36cba0273c77263d89e (diff) | |
download | nextcloud-server-db946256f9949e20b95fd07daa95cb2e5f51fa2e.tar.gz nextcloud-server-db946256f9949e20b95fd07daa95cb2e5f51fa2e.zip |
add test case for increasesize
-rw-r--r-- | tests/lib/filesystem.php | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php index 1fc2c270123..c817f96ed16 100644 --- a/tests/lib/filesystem.php +++ b/tests/lib/filesystem.php @@ -26,6 +26,8 @@ class Test_Filesystem extends UnitTestCase { */ private $tmpDirs; + private $user; + /** * @return array */ @@ -45,6 +47,26 @@ class Test_Filesystem extends UnitTestCase { OC_Filesystem::clearMounts(); } + private function setupTempMount() { + if(! $this->user){ + if (OC_Filesystem::getView()) { + $user = OC_User::getUser(); + } else { + $user = uniqid(); + OC_Filesystem::init('/' . $user . '/files'); + } + $this->user=$user; + }else{ + $user=$this->user; + } + + OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/'); + + $rootView = new OC_FilesystemView(''); + $rootView->mkdir('/' . $user); + $rootView->mkdir('/' . $user . '/files'); + } + public function testMount() { OC_Filesystem::mount('OC_Filestorage_Local', self::getStorageData(), '/'); $this->assertEqual('/', OC_Filesystem::getMountPoint('/')); @@ -88,18 +110,9 @@ class Test_Filesystem extends UnitTestCase { ); $this->assertFalse($run); - if (OC_Filesystem::getView()) { - $user = OC_User::getUser(); - } else { - $user = uniqid(); - OC_Filesystem::init('/' . $user . '/files'); - } - - OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/'); + $this->setupTempMount(); $rootView = new OC_FilesystemView(''); - $rootView->mkdir('/' . $user); - $rootView->mkdir('/' . $user . '/files'); $this->assertFalse($rootView->file_put_contents('/.htaccess', 'foo')); $this->assertFalse(OC_Filesystem::file_put_contents('/.htaccess', 'foo')); @@ -108,20 +121,10 @@ class Test_Filesystem extends UnitTestCase { } public function testHooks() { - if(OC_Filesystem::getView()){ - $user = OC_User::getUser(); - }else{ - $user=uniqid(); - OC_Filesystem::init('/'.$user.'/files'); - } OC_Hook::clear('OC_Filesystem'); OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); - OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/'); - - $rootView=new OC_FilesystemView(''); - $rootView->mkdir('/'.$user); - $rootView->mkdir('/'.$user.'/files'); + $this->setupTempMount(); OC_Filesystem::file_put_contents('/foo', 'foo'); OC_Filesystem::mkdir('/bar'); @@ -137,4 +140,35 @@ class Test_Filesystem extends UnitTestCase { $path = $arguments['path']; $this->assertEqual($path, OC_Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized } + + public function testSizeIncrease(){ + OC_Hook::clear('OC_Filesystem'); + OC_Hook::connect('OC_Filesystem', 'post_write','OC_FileCache_Update', 'fileSystemWatcherWrite'); + OC_Hook::connect('OC_Filesystem', 'post_delete','OC_FileCache_Update', 'fileSystemWatcherDelete'); + OC_Hook::connect('OC_Filesystem', 'post_rename','OC_FileCache_Update', 'fileSystemWatcherRename'); + + $this->setupTempMount(); + + // folder is empty + OC_FileCache::scan(''); + $item = OC_FileCache_Cached::get(''); + $this->assertEqual(0, $item['size']); + + OC_Filesystem::file_put_contents('/foo', 'foo'); + + $item = OC_FileCache_Cached::get(''); + $this->assertEqual(3, $item['size']); + + OC_Filesystem::unlink('/foo'); + $item = OC_FileCache_Cached::get(''); + $this->assertEqual(0, $item['size']); + + OC_Filesystem::mkdir('/bar'); + OC_Filesystem::file_put_contents('/bar/foo', 'foo'); + + $item = OC_FileCache_Cached::get(''); + $this->assertEqual(3, $item['size']); + + OC_FileCache::delete(''); + } } |