diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-03-28 12:08:38 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-03-28 12:08:38 +0100 |
commit | 040f430f0c2c3f1de1d2e24b183c1634c3067adb (patch) | |
tree | 09a5793725aa14c0675c51d2d2d767066b5e2672 /tests/lib/files | |
parent | 1e9c5be33d5a7a447168c2e293191e49f8231d21 (diff) | |
parent | e76be308eb8e969b1a4b74d97c2ccb320a986937 (diff) | |
download | nextcloud-server-040f430f0c2c3f1de1d2e24b183c1634c3067adb.tar.gz nextcloud-server-040f430f0c2c3f1de1d2e24b183c1634c3067adb.zip |
Merge pull request #7829 from owncloud/cachefolderlocation
Cache folder is now configurable
Diffstat (limited to 'tests/lib/files')
-rw-r--r-- | tests/lib/files/filesystem.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index 90f1dfe581b..53f528af793 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -226,4 +226,55 @@ class Filesystem extends \PHPUnit_Framework_TestCase { $path = $arguments['path']; $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); + } } |