diff options
author | Frank Karlitschek <frank@owncloud.org> | 2013-11-13 22:43:18 +0400 |
---|---|---|
committer | Frank Karlitschek <frank@owncloud.org> | 2013-11-13 22:43:18 +0400 |
commit | 8d0d0836bae968d3abff5f5ff9db230d449397a6 (patch) | |
tree | 1e860674e40972644148ebd9614981d2ff1f34de /tests/lib/files/filesystem.php | |
parent | cd4a816c1187639ce6e3982b308c637bdd3f20e9 (diff) | |
parent | 58ff8a86733973980370b4e639203d32b2663d9a (diff) |
Merge branch 'master' of https://github.com/owncloud/corev6.0.0beta4
Diffstat (limited to 'tests/lib/files/filesystem.php')
-rw-r--r-- | tests/lib/files/filesystem.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index bef70cc725b..990e95ca595 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -41,9 +41,12 @@ class Filesystem extends \PHPUnit_Framework_TestCase { foreach ($this->tmpDirs as $dir) { \OC_Helper::rmdirr($dir); } + \OC\Files\Filesystem::clearMounts(); + \OC_User::setUserId(''); } public function setUp() { + \OC_User::setUserId(''); \OC\Files\Filesystem::clearMounts(); } @@ -103,6 +106,67 @@ class Filesystem extends \PHPUnit_Framework_TestCase { // \OC\Files\Filesystem::file_put_contents('/bar//foo', $fh); } + /** + * Tests that a local storage mount is used when passed user + * does not exist. + */ + public function testLocalMountWhenUserDoesNotExist() { + $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); + $userId = uniqid('user_'); + + \OC\Files\Filesystem::initMountPoints($userId); + + $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/'); + + $this->assertInstanceOf('\OC\Files\Storage\Local', $homeMount); + $this->assertEquals('local::' . $datadir . '/' . $userId . '/', $homeMount->getId()); + } + + /** + * Tests that the home storage is used for the user's mount point + */ + public function testHomeMount() { + $userId = uniqid('user_'); + + \OC_User::createUser($userId, $userId); + + \OC\Files\Filesystem::initMountPoints($userId); + + $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/'); + + $this->assertInstanceOf('\OC\Files\Storage\Home', $homeMount); + $this->assertEquals('home::' . $userId, $homeMount->getId()); + + \OC_User::deleteUser($userId); + } + + /** + * Tests that the home storage is used in legacy mode + * for the user's mount point + */ + public function testLegacyHomeMount() { + $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); + $userId = uniqid('user_'); + + // insert storage into DB by constructing it + // to make initMountsPoint find its existence + $localStorage = new \OC\Files\Storage\Local(array('datadir' => $datadir . '/' . $userId . '/')); + // this will trigger the insert + $cache = $localStorage->getCache(); + + \OC_User::createUser($userId, $userId); + \OC\Files\Filesystem::initMountPoints($userId); + + $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/'); + + $this->assertInstanceOf('\OC\Files\Storage\Home', $homeMount); + $this->assertEquals('local::' . $datadir. '/' . $userId . '/', $homeMount->getId()); + + \OC_User::deleteUser($userId); + // delete storage entry + $cache->clear(); + } + public function dummyHook($arguments) { $path = $arguments['path']; $this->assertEquals($path, \OC\Files\Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized |