Skip to content
Snippets Groups Projects
Commit 1e397199 authored by Vincent Petry's avatar Vincent Petry
Browse files

Added unit tests for external cache folder

parent 10c9b8eb
No related branches found
No related tags found
No related merge requests found
...@@ -226,4 +226,55 @@ class Filesystem extends \PHPUnit_Framework_TestCase { ...@@ -226,4 +226,55 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
$path = $arguments['path']; $path = $arguments['path'];
$this->assertEquals($path, \OC\Files\Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized $this->assertEquals($path, \OC\Files\Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized
} }
/**
* Test that the default cache dir is part of the user's home
*/
public function testMountDefaultCacheDir() {
$userId = uniqid('user_');
$oldCachePath = \OC_Config::getValue('cache_path', '');
// no cache path configured
\OC_Config::setValue('cache_path', '');
\OC_User::createUser($userId, $userId);
\OC\Files\Filesystem::initMountPoints($userId);
$this->assertEquals(
'/' . $userId . '/',
\OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache')
);
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
$this->assertInstanceOf('\OC\Files\Storage\Home', $storage);
$this->assertEquals('cache', $internalPath);
\OC_User::deleteUser($userId);
\OC_Config::setValue('cache_path', $oldCachePath);
}
/**
* Test that an external cache is mounted into
* the user's home
*/
public function testMountExternalCacheDir() {
$userId = uniqid('user_');
$oldCachePath = \OC_Config::getValue('cache_path', '');
// set cache path to temp dir
$cachePath = \OC_Helper::tmpFolder() . '/extcache';
\OC_Config::setValue('cache_path', $cachePath);
\OC_User::createUser($userId, $userId);
\OC\Files\Filesystem::initMountPoints($userId);
$this->assertEquals(
'/' . $userId . '/cache/',
\OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache')
);
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
$this->assertInstanceOf('\OC\Files\Storage\Local', $storage);
$this->assertEquals('', $internalPath);
\OC_User::deleteUser($userId);
\OC_Config::setValue('cache_path', $oldCachePath);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment