*/
private $files;
- private $originalStorage;
-
protected function setUp() {
parent::setUp();
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
-
// mock OC_L10n
if (!self::$user) {
self::$user = uniqid();
}
\OC_User::createUser(self::$user, 'password');
- \OC_User::setUserId(self::$user);
-
- \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
+ $this->loginAsUser(self::$user);
$l10nMock = $this->getMock('\OC_L10N', array('t'), array(), '', false);
$l10nMock->expects($this->any())
protected function tearDown() {
$result = \OC_User::deleteUser(self::$user);
$this->assertTrue($result);
- \OC\Files\Filesystem::tearDown();
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+ $this->logout();
parent::tearDown();
}
*/
private $user;
- /**
- * @var \OC\Files\Storage\Storage
- **/
- private $originalStorage;
-
/**
* @var \OC\Files\View
*/
// this will setup the FS
$this->loginAsUser($this->user);
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
-
\OCA\Files_Trashbin\Storage::setupStorage();
$this->rootView = new \OC\Files\View('/');
protected function tearDown() {
\OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
$this->logout();
\OC_User::deleteUser($this->user);
\OC_Hook::clear();
*/
protected $updater;
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
protected function setUp() {
parent::setUp();
- $this->originalStorage = Filesystem::getStorage('/');
+ $this->loginAsUser();
$this->storage = new Temporary(array());
- Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/');
$this->view = new View('');
$this->updater = new \OC\Files\Cache\Updater($this->view);
protected function tearDown() {
Filesystem::clearMounts();
- Filesystem::mount($this->originalStorage, array(), '/');
+ $this->logout();
parent::tearDown();
}
*/
private $cache;
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
private static $user;
protected function setUp() {
$this->scanner->scan('');
$this->cache = $this->storage->getCache();
- $this->originalStorage = Filesystem::getStorage('/');
- Filesystem::tearDown();
if (!self::$user) {
self::$user = $this->getUniqueID();
}
\OC_User::createUser(self::$user, 'password');
- \OC_User::setUserId(self::$user);
+ $this->loginAsUser(self::$user);
Filesystem::init(self::$user, '/' . self::$user . '/files');
}
$result = \OC_User::deleteUser(self::$user);
$this->assertTrue($result);
- Filesystem::tearDown();
- Filesystem::mount($this->originalStorage, array(), '/');
+ $this->logout();
parent::tearDown();
}
*/
private $storages = array();
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
protected function setUp() {
parent::setUp();
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
- \OC\Files\Filesystem::clearMounts();
+ $this->loginAsUser();
}
protected function tearDown() {
$cache->clear();
}
- \OC\Files\Filesystem::clearMounts();
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
-
+ $this->logout();
parent::tearDown();
}
private $tmpDir;
- private $uid;
-
/**
* @var \OC_User_Dummy $userBackend
*/
private $userBackend;
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
protected function setUp() {
parent::setUp();
$this->datadir = \OC_Config::getValue('datadirectory');
$this->tmpDir = \OC_Helper::tmpFolder();
\OC_Config::setValue('datadirectory', $this->tmpDir);
- $this->uid = \OC_User::getUser();
- \OC_User::setUserId(null);
$this->userBackend = new \OC_User_Dummy();
\OC_User::useBackend($this->userBackend);
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
- \OC_Util::tearDownFS();
}
protected function tearDown() {
\OC_Config::setValue('datadirectory', $this->datadir);
- \OC_User::setUserId($this->uid);
- \OC_Util::setupFS($this->uid);
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+ $this->logout();
parent::tearDown();
}
$user1 = $this->getUniqueID('user_');
$this->userBackend->createUser($user1, '');
- \OC_Util::tearDownFS();
- \OC_User::setUserId($user1);
- \OC_Util::setupFS($user1);
+ $this->loginAsUser($user1);
Filesystem::mkdir('/folder');
Filesystem::mkdir('/folder/subfolder');
Filesystem::file_put_contents('/foo.txt', 'asd');
*/
private $tmpDirs = array();
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
/**
* @return array
*/
protected function setUp() {
parent::setUp();
-
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
- \OC_User::setUserId('');
- \OC\Files\Filesystem::clearMounts();
+ $this->loginAsUser();
}
protected function tearDown() {
foreach ($this->tmpDirs as $dir) {
\OC_Helper::rmdirr($dir);
}
- \OC\Files\Filesystem::clearMounts();
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
- \OC_User::setUserId('');
+ $this->logout();
parent::tearDown();
}
*/
private $root;
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
/**
* @var \OC\Files\Storage\Storage[]
*/
protected function setUp() {
parent::setUp();
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
- \OC\Files\Filesystem::init('', '');
- \OC\Files\Filesystem::clearMounts();
$manager = \OC\Files\Filesystem::getMountManager();
\OC_Hook::clear('OC_Filesystem');
\OC_Hook::connect('OC_Filesystem', 'post_touch', '\OC\Files\Cache\Updater', 'touchHook');
$user = new User($this->getUniqueID('user'), new \OC_User_Dummy);
- \OC_User::setUserId($user->getUID());
+ $this->loginAsUser($user->getUID());
+
$this->view = new View();
$this->root = new Root($manager, $this->view, $user);
$storage = new Temporary(array());
foreach ($this->storages as $storage) {
$storage->getCache()->clear();
}
- \OC\Files\Filesystem::clearMounts();
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+ $this->logout();
parent::tearDown();
}
}
class Scanner extends \Test\TestCase {
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
protected function setUp() {
parent::setUp();
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
+ $this->loginAsUser();
}
protected function tearDown() {
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
-
+ $this->logout();
parent::tearDown();
}
/** @var \OC\Files\Storage\Storage */
private $tempStorage;
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
protected function setUp() {
parent::setUp();
//login
\OC_User::createUser('test', 'test');
$this->user = \OC_User::getUser();
- \OC_User::setUserId('test');
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
+ $this->loginAsUser('test');
+ // clear mounts but somehow keep the root storage
+ // that was initialized above...
\OC\Files\Filesystem::clearMounts();
$this->tempStorage = null;
system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
}
- \OC\Files\Filesystem::clearMounts();
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
-
+ $this->logout();
parent::tearDown();
}
protected function setUp() {
parent::setUp();
+ // FIXME: use proper tearDown with $this->loginAsUser() and $this->logout()
+ // (would currently break the tests for some reason)
$this->originalStorage = \OC\Files\Filesystem::getStorage('/');
// create a new user with his own filesystem view
}
public function testOC() {
+ // FIXME: use proper tearDown with $this->loginAsUser() and $this->logout()
+ // (would currently break the tests for some reason)
$originalStorage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
* Login and setup FS as a given user,
* sets the given user as the current user.
*
- * @param string $user user id
+ * @param string $user user id or empty for a generic FS
*/
- static protected function loginAsUser($user) {
+ static protected function loginAsUser($user = '') {
self::logout();
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId($user);