*/
private $files;
- function setUp() {
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
+
// mock OC_L10n
if (!self::$user) {
self::$user = uniqid();
$this->files = new \OCA\Files\App($viewMock, $l10nMock);
}
- function tearDown() {
+ protected function tearDown() {
$result = \OC_User::deleteUser(self::$user);
$this->assertTrue($result);
\OC\Files\Filesystem::tearDown();
+ \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+
+ parent::tearDown();
}
/**
namespace Test\Cache;
class FileCache extends \Test_Cache {
+ /** @var string */
private $user;
+ /** @var string */
private $datadir;
+ /** @var \OC\Files\Storage\Storage */
+ private $storage;
function skip() {
//$this->skipUnless(OC_User::isLoggedIn());
//}
//set up temporary storage
+ $this->storage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage,array(),'/');
public function tearDown() {
\OC_User::setUserId($this->user);
\OC_Config::setValue('datadirectory', $this->datadir);
+
+ // Restore the original mount point
+ \OC\Files\Filesystem::clearMounts();
+ \OC\Files\Filesystem::mount($this->storage, array(), '/');
+
+ parent::tearDown();
}
}
namespace Test\Cache;
class UserCache extends \Test_Cache {
+ /** @var string */
private $user;
+ /** @var string */
private $datadir;
+ /** @var \OC\Files\Storage\Storage */
+ private $storage;
public function setUp() {
//clear all proxies and hooks so we can do clean testing
//}
//set up temporary storage
+ $this->storage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage,array(),'/');
public function tearDown() {
\OC_User::setUserId($this->user);
\OC_Config::setValue('datadirectory', $this->datadir);
+
+ // Restore the original mount point
+ \OC\Files\Filesystem::clearMounts();
+ \OC\Files\Filesystem::mount($this->storage, array(), '/');
+
+ parent::tearDown();
}
}
*/
protected $updater;
- public function setUp() {
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = Filesystem::getStorage('/');
$this->storage = new Temporary(array());
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/');
$this->cache = $this->storage->getCache();
}
+ protected function tearDown() {
+ Filesystem::clearMounts();
+ Filesystem::mount($this->originalStorage, array(), '/');
+
+ parent::tearDown();
+ }
+
public function testNewFile() {
$this->storage->file_put_contents('foo.txt', 'bar');
$this->assertFalse($this->cache->inCache('foo.txt'));
*/
private $cache;
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
private static $user;
public function setUp() {
$this->scanner->scan('');
$this->cache = $this->storage->getCache();
- \OC\Files\Filesystem::tearDown();
+ $this->originalStorage = Filesystem::getStorage('/');
+ Filesystem::tearDown();
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');
+ Filesystem::init(self::$user, '/' . self::$user . '/files');
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
$result = \OC_User::deleteUser(self::$user);
$this->assertTrue($result);
Filesystem::tearDown();
+ Filesystem::mount($this->originalStorage, array(), '/');
// reset app files_encryption
if ($this->stateFilesEncryption) {
\OC_App::enable('files_encryption');
*/
private $storages = array();
- public function setUp() {
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
}
- public function tearDown() {
+ protected function tearDown() {
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
$ids = $cache->getAll();
$cache->clear();
}
+
+ \OC\Files\Filesystem::clearMounts();
+ \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+
+ parent::tearDown();
}
/**
use OC\Files\Filesystem;
use OCP\Share;
-class EtagTest extends \PHPUnit_Framework_TestCase {
+class EtagTest extends \Test\TestCase {
private $datadir;
private $tmpDir;
*/
private $userBackend;
- public function setUp() {
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
\OC_Hook::clear('OC_Filesystem', 'setup');
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
$this->userBackend = new \OC_User_Dummy();
\OC_User::useBackend($this->userBackend);
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
\OC_Util::tearDownFS();
}
- public function tearDown() {
+ 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(), '/');
+
+ parent::tearDown();
}
public function testNewUser() {
namespace Test\Files;
-class Filesystem extends \PHPUnit_Framework_TestCase {
+class Filesystem extends \Test\TestCase {
/**
* @var array tmpDirs
*/
private $tmpDirs = array();
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
/**
* @return array
*/
return array('datadir' => $dir);
}
- public function tearDown() {
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
+ \OC_User::setUserId('');
+ \OC\Files\Filesystem::clearMounts();
+ }
+
+ 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('');
}
- public function setUp() {
- \OC_User::setUserId('');
- \OC\Files\Filesystem::clearMounts();
- }
-
public function testMount() {
\OC\Files\Filesystem::mount('\OC\Files\Storage\Local', self::getStorageData(), '/');
$this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/'));
*/
private $root;
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
/**
* @var \OC\Files\Storage\Storage[]
*/
*/
private $view;
- public function setUp() {
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::init('', '');
\OC\Files\Filesystem::clearMounts();
$manager = \OC\Files\Filesystem::getMountManager();
$this->root->mount($subStorage, '/substorage/');
}
- public function tearDown() {
+ protected function tearDown() {
foreach ($this->storages as $storage) {
$storage->getCache()->clear();
}
\OC\Files\Filesystem::clearMounts();
+
+ \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+
+ parent::tearDown();
}
public function testBasicFile() {
}
}
-class Scanner extends \PHPUnit_Framework_TestCase {
+
+class Scanner extends \Test\TestCase {
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
+ }
+
+ protected function tearDown() {
+ \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+
+ parent::tearDown();
+ }
+
public function testReuseExistingRoot() {
$storage = new Temporary(array());
$mount = new Mount($storage, '');
private $storages = array();
private $user;
+ /** @var \OC\Files\Storage\Storage */
private $tempStorage;
- public function setUp() {
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
\OC_User::clearBackends();
\OC_User::useBackend(new \OC_User_Dummy());
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
$this->tempStorage = null;
}
- public function tearDown() {
+ protected function tearDown() {
\OC_User::setUserId($this->user);
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
}
+
+ \OC\Files\Filesystem::clearMounts();
+ \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+
+ parent::tearDown();
}
/**
/**
* Test the storage functions of OC_Helper
*/
-class Test_Helper_Storage extends PHPUnit_Framework_TestCase {
+
+class Test_Helper_Storage extends \Test\TestCase {
+ /** @var string */
private $user;
+ /** @var \OC\Files\Storage\Storage */
private $storageMock;
+ /** @var \OC\Files\Storage\Storage */
+ private $storage;
+
+ protected function setUp() {
+ parent::setUp();
- public function setUp() {
- $this->user = 'user_' . uniqid();
+ $this->user = $this->getUniqueID('user_');
\OC_User::createUser($this->user, $this->user);
+ $this->storage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId($this->user);
\OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files');
$this->storageMock = null;
}
- public function tearDown() {
+ protected function tearDown() {
$this->user = null;
if ($this->storageMock) {
$this->storageMock = null;
}
\OC\Files\Filesystem::tearDown();
+ \OC\Files\Filesystem::mount($this->storage, array(), '/');
\OC_User::setUserId('');
\OC_User::deleteUser($this->user);
\OC_Preferences::deleteUser($this->user);
+
+ parent::tearDown();
}
/**
public $users;
public $tmpfiles = array();
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
+ }
+
+ protected function tearDown() {
+ $u = new OC_User();
+ foreach($this->users as $user) {
+ $u->deleteUser($user);
+ }
+ foreach($this->tmpfiles as $file) {
+ \OC_Helper::rmdirr($file);
+ }
+
+ \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+ parent::tearDown();
+ }
+
/**
* Generates a test user and sets up their file system
* @return string the test users id
// Validate the export
$this->validateUserExport($user2, $user, json_decode($export)->data);
}
-
- public function tearDown() {
- $u = new OC_User();
- foreach($this->users as $user) {
- $u->deleteUser($user);
- }
- foreach($this->tmpfiles as $file) {
- \OC_Helper::rmdirr($file);
- }
- }
-
-
-
-
}
namespace Test;
-class Preview extends \PHPUnit_Framework_TestCase {
+class Preview extends \Test\TestCase {
/**
* @var string
*/
private $rootView;
- public function setUp() {
- $this->user = $this->initFS();
+ /** @var \OC\Files\Storage\Storage */
+ private $originalStorage;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
+
+ // create a new user with his own filesystem view
+ // this gets called by each test in this test class
+ $this->user = $this->getUniqueID();
+ \OC_User::setUserId($this->user);
+ \OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files');
+
+ \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/');
$this->rootView = new \OC\Files\View('');
$this->rootView->mkdir('/'.$this->user);
$this->rootView->mkdir('/'.$this->user.'/files');
}
+ protected function tearDown() {
+ \OC\Files\Filesystem::clearMounts();
+ \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
+
+ parent::tearDown();
+ }
+
public function testIsPreviewDeleted() {
$sampleFile = '/'.$this->user.'/files/test.txt';
$this->assertEquals($this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/150-150.png', $isCached);
}
*/
-
- private function initFS() {
- // create a new user with his own filesystem view
- // this gets called by each test in this test class
- $user=uniqid();
- \OC_User::setUserId($user);
- \OC\Files\Filesystem::init($user, '/'.$user.'/files');
-
- \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/');
-
- return $user;
- }
}
}
public function testOC() {
+ $originalStorage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
+
$storage = new \OC\Files\Storage\Temporary(array());
$storage->file_put_contents('foo.txt', 'asd');
\OC\Files\Filesystem::mount($storage, array(), '/');
unlink('oc:///foo.txt');
$this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
+
+ \OC\Files\Filesystem::clearMounts();
+ \OC\Files\Filesystem::mount($originalStorage, array(), '/');
}
}