|
|
|
@ -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 |
|
|
|
|