Correctly restore previous root mount point after testing
This commit is contained in:
parent
289a27778e
commit
6625d5c88f
|
@ -34,7 +34,14 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
private $files;
|
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
|
// mock OC_L10n
|
||||||
if (!self::$user) {
|
if (!self::$user) {
|
||||||
self::$user = uniqid();
|
self::$user = uniqid();
|
||||||
|
@ -59,10 +66,13 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
|
||||||
$this->files = new \OCA\Files\App($viewMock, $l10nMock);
|
$this->files = new \OCA\Files\App($viewMock, $l10nMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
protected function tearDown() {
|
||||||
$result = \OC_User::deleteUser(self::$user);
|
$result = \OC_User::deleteUser(self::$user);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
\OC\Files\Filesystem::tearDown();
|
\OC\Files\Filesystem::tearDown();
|
||||||
|
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,8 +23,12 @@
|
||||||
namespace Test\Cache;
|
namespace Test\Cache;
|
||||||
|
|
||||||
class FileCache extends \Test_Cache {
|
class FileCache extends \Test_Cache {
|
||||||
|
/** @var string */
|
||||||
private $user;
|
private $user;
|
||||||
|
/** @var string */
|
||||||
private $datadir;
|
private $datadir;
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $storage;
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
//$this->skipUnless(OC_User::isLoggedIn());
|
//$this->skipUnless(OC_User::isLoggedIn());
|
||||||
|
@ -42,6 +46,7 @@ class FileCache extends \Test_Cache {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//set up temporary storage
|
//set up temporary storage
|
||||||
|
$this->storage = \OC\Files\Filesystem::getStorage('/');
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
$storage = new \OC\Files\Storage\Temporary(array());
|
$storage = new \OC\Files\Storage\Temporary(array());
|
||||||
\OC\Files\Filesystem::mount($storage,array(),'/');
|
\OC\Files\Filesystem::mount($storage,array(),'/');
|
||||||
|
@ -68,5 +73,11 @@ class FileCache extends \Test_Cache {
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
\OC_User::setUserId($this->user);
|
\OC_User::setUserId($this->user);
|
||||||
\OC_Config::setValue('cachedirectory', $this->datadir);
|
\OC_Config::setValue('cachedirectory', $this->datadir);
|
||||||
|
|
||||||
|
// Restore the original mount point
|
||||||
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
\OC\Files\Filesystem::mount($this->storage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,12 @@
|
||||||
namespace Test\Cache;
|
namespace Test\Cache;
|
||||||
|
|
||||||
class UserCache extends \Test_Cache {
|
class UserCache extends \Test_Cache {
|
||||||
|
/** @var string */
|
||||||
private $user;
|
private $user;
|
||||||
|
/** @var string */
|
||||||
private $datadir;
|
private $datadir;
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $storage;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
//clear all proxies and hooks so we can do clean testing
|
//clear all proxies and hooks so we can do clean testing
|
||||||
|
@ -38,6 +42,7 @@ class UserCache extends \Test_Cache {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//set up temporary storage
|
//set up temporary storage
|
||||||
|
$this->storage = \OC\Files\Filesystem::getStorage('/');
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
$storage = new \OC\Files\Storage\Temporary(array());
|
$storage = new \OC\Files\Storage\Temporary(array());
|
||||||
\OC\Files\Filesystem::mount($storage,array(),'/');
|
\OC\Files\Filesystem::mount($storage,array(),'/');
|
||||||
|
@ -63,5 +68,12 @@ class UserCache extends \Test_Cache {
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
\OC_User::setUserId($this->user);
|
\OC_User::setUserId($this->user);
|
||||||
|
\OC_Config::setValue('cachedirectory', $this->datadir);
|
||||||
|
|
||||||
|
// Restore the original mount point
|
||||||
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
\OC\Files\Filesystem::mount($this->storage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,13 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
protected $updater;
|
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());
|
$this->storage = new Temporary(array());
|
||||||
Filesystem::clearMounts();
|
Filesystem::clearMounts();
|
||||||
Filesystem::mount($this->storage, array(), '/');
|
Filesystem::mount($this->storage, array(), '/');
|
||||||
|
@ -42,6 +48,13 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$this->cache = $this->storage->getCache();
|
$this->cache = $this->storage->getCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function tearDown() {
|
||||||
|
Filesystem::clearMounts();
|
||||||
|
Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
public function testNewFile() {
|
public function testNewFile() {
|
||||||
$this->storage->file_put_contents('foo.txt', 'bar');
|
$this->storage->file_put_contents('foo.txt', 'bar');
|
||||||
$this->assertFalse($this->cache->inCache('foo.txt'));
|
$this->assertFalse($this->cache->inCache('foo.txt'));
|
||||||
|
|
|
@ -29,6 +29,9 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
private $cache;
|
private $cache;
|
||||||
|
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $originalStorage;
|
||||||
|
|
||||||
private static $user;
|
private static $user;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
@ -51,7 +54,8 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
|
||||||
$this->scanner->scan('');
|
$this->scanner->scan('');
|
||||||
$this->cache = $this->storage->getCache();
|
$this->cache = $this->storage->getCache();
|
||||||
|
|
||||||
\OC\Files\Filesystem::tearDown();
|
$this->originalStorage = Filesystem::getStorage('/');
|
||||||
|
Filesystem::tearDown();
|
||||||
if (!self::$user) {
|
if (!self::$user) {
|
||||||
self::$user = uniqid();
|
self::$user = uniqid();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +63,7 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
|
||||||
\OC_User::createUser(self::$user, 'password');
|
\OC_User::createUser(self::$user, 'password');
|
||||||
\OC_User::setUserId(self::$user);
|
\OC_User::setUserId(self::$user);
|
||||||
|
|
||||||
\OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
|
Filesystem::init(self::$user, '/' . self::$user . '/files');
|
||||||
|
|
||||||
Filesystem::clearMounts();
|
Filesystem::clearMounts();
|
||||||
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
|
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
|
||||||
|
@ -74,6 +78,7 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
|
||||||
$result = \OC_User::deleteUser(self::$user);
|
$result = \OC_User::deleteUser(self::$user);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
Filesystem::tearDown();
|
Filesystem::tearDown();
|
||||||
|
Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
// reset app files_encryption
|
// reset app files_encryption
|
||||||
if ($this->stateFilesEncryption) {
|
if ($this->stateFilesEncryption) {
|
||||||
\OC_App::enable('files_encryption');
|
\OC_App::enable('files_encryption');
|
||||||
|
|
|
@ -15,16 +15,27 @@ class Watcher extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
private $storages = array();
|
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();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
protected function tearDown() {
|
||||||
foreach ($this->storages as $storage) {
|
foreach ($this->storages as $storage) {
|
||||||
$cache = $storage->getCache();
|
$cache = $storage->getCache();
|
||||||
$ids = $cache->getAll();
|
$ids = $cache->getAll();
|
||||||
$cache->clear();
|
$cache->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Test\Files;
|
||||||
use OC\Files\Filesystem;
|
use OC\Files\Filesystem;
|
||||||
use OCP\Share;
|
use OCP\Share;
|
||||||
|
|
||||||
class EtagTest extends \PHPUnit_Framework_TestCase {
|
class EtagTest extends \Test\TestCase {
|
||||||
private $datadir;
|
private $datadir;
|
||||||
|
|
||||||
private $tmpDir;
|
private $tmpDir;
|
||||||
|
@ -23,7 +23,12 @@ class EtagTest extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
private $userBackend;
|
private $userBackend;
|
||||||
|
|
||||||
public function setUp() {
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $originalStorage;
|
||||||
|
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
\OC_Hook::clear('OC_Filesystem', 'setup');
|
\OC_Hook::clear('OC_Filesystem', 'setup');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
|
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
|
||||||
\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
|
\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
|
||||||
|
@ -37,13 +42,17 @@ class EtagTest extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
$this->userBackend = new \OC_User_Dummy();
|
$this->userBackend = new \OC_User_Dummy();
|
||||||
\OC_User::useBackend($this->userBackend);
|
\OC_User::useBackend($this->userBackend);
|
||||||
|
$this->originalStorage = \OC\Files\Filesystem::getStorage('/');
|
||||||
\OC_Util::tearDownFS();
|
\OC_Util::tearDownFS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
protected function tearDown() {
|
||||||
\OC_Config::setValue('datadirectory', $this->datadir);
|
\OC_Config::setValue('datadirectory', $this->datadir);
|
||||||
\OC_User::setUserId($this->uid);
|
\OC_User::setUserId($this->uid);
|
||||||
\OC_Util::setupFS($this->uid);
|
\OC_Util::setupFS($this->uid);
|
||||||
|
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNewUser() {
|
public function testNewUser() {
|
||||||
|
|
|
@ -22,12 +22,15 @@
|
||||||
|
|
||||||
namespace Test\Files;
|
namespace Test\Files;
|
||||||
|
|
||||||
class Filesystem extends \PHPUnit_Framework_TestCase {
|
class Filesystem extends \Test\TestCase {
|
||||||
/**
|
/**
|
||||||
* @var array tmpDirs
|
* @var array tmpDirs
|
||||||
*/
|
*/
|
||||||
private $tmpDirs = array();
|
private $tmpDirs = array();
|
||||||
|
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $originalStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -37,19 +40,23 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
|
||||||
return array('datadir' => $dir);
|
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) {
|
foreach ($this->tmpDirs as $dir) {
|
||||||
\OC_Helper::rmdirr($dir);
|
\OC_Helper::rmdirr($dir);
|
||||||
}
|
}
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
\OC_User::setUserId('');
|
\OC_User::setUserId('');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp() {
|
|
||||||
\OC_User::setUserId('');
|
|
||||||
\OC\Files\Filesystem::clearMounts();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMount() {
|
public function testMount() {
|
||||||
\OC\Files\Filesystem::mount('\OC\Files\Storage\Local', self::getStorageData(), '/');
|
\OC\Files\Filesystem::mount('\OC\Files\Storage\Local', self::getStorageData(), '/');
|
||||||
$this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/'));
|
$this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/'));
|
||||||
|
|
|
@ -20,6 +20,9 @@ class IntegrationTests extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
private $root;
|
private $root;
|
||||||
|
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $originalStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OC\Files\Storage\Storage[]
|
* @var \OC\Files\Storage\Storage[]
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +33,10 @@ class IntegrationTests extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
private $view;
|
private $view;
|
||||||
|
|
||||||
public function setUp() {
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->originalStorage = \OC\Files\Filesystem::getStorage('/');
|
||||||
\OC\Files\Filesystem::init('', '');
|
\OC\Files\Filesystem::init('', '');
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
$manager = \OC\Files\Filesystem::getMountManager();
|
$manager = \OC\Files\Filesystem::getMountManager();
|
||||||
|
@ -54,11 +60,15 @@ class IntegrationTests extends \PHPUnit_Framework_TestCase {
|
||||||
$this->root->mount($subStorage, '/substorage/');
|
$this->root->mount($subStorage, '/substorage/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
protected function tearDown() {
|
||||||
foreach ($this->storages as $storage) {
|
foreach ($this->storages as $storage) {
|
||||||
$storage->getCache()->clear();
|
$storage->getCache()->clear();
|
||||||
}
|
}
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
|
||||||
|
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicFile() {
|
public function testBasicFile() {
|
||||||
|
|
|
@ -38,7 +38,23 @@ class TestScanner extends \OC\Files\Utils\Scanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
public function testReuseExistingRoot() {
|
||||||
$storage = new Temporary(array());
|
$storage = new Temporary(array());
|
||||||
$mount = new Mount($storage, '');
|
$mount = new Mount($storage, '');
|
||||||
|
|
|
@ -22,9 +22,15 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
private $storages = array();
|
private $storages = array();
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
private $tempStorage;
|
private $tempStorage;
|
||||||
|
|
||||||
public function setUp() {
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $originalStorage;
|
||||||
|
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
\OC_User::clearBackends();
|
\OC_User::clearBackends();
|
||||||
\OC_User::useBackend(new \OC_User_Dummy());
|
\OC_User::useBackend(new \OC_User_Dummy());
|
||||||
|
|
||||||
|
@ -33,12 +39,13 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
$this->user = \OC_User::getUser();
|
$this->user = \OC_User::getUser();
|
||||||
\OC_User::setUserId('test');
|
\OC_User::setUserId('test');
|
||||||
|
|
||||||
|
$this->originalStorage = \OC\Files\Filesystem::getStorage('/');
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
|
||||||
$this->tempStorage = null;
|
$this->tempStorage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
protected function tearDown() {
|
||||||
\OC_User::setUserId($this->user);
|
\OC_User::setUserId($this->user);
|
||||||
foreach ($this->storages as $storage) {
|
foreach ($this->storages as $storage) {
|
||||||
$cache = $storage->getCache();
|
$cache = $storage->getCache();
|
||||||
|
@ -49,6 +56,11 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
|
if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
|
||||||
system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
|
system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,14 +9,22 @@
|
||||||
/**
|
/**
|
||||||
* Test the storage functions of OC_Helper
|
* Test the storage functions of OC_Helper
|
||||||
*/
|
*/
|
||||||
class Test_Helper_Storage extends PHPUnit_Framework_TestCase {
|
|
||||||
private $user;
|
|
||||||
private $storageMock;
|
|
||||||
|
|
||||||
public function setUp() {
|
class Test_Helper_Storage extends \Test\TestCase {
|
||||||
$this->user = 'user_' . uniqid();
|
/** @var string */
|
||||||
|
private $user;
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $storageMock;
|
||||||
|
/** @var \OC\Files\Storage\Storage */
|
||||||
|
private $storage;
|
||||||
|
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->user = $this->getUniqueID('user_');
|
||||||
\OC_User::createUser($this->user, $this->user);
|
\OC_User::createUser($this->user, $this->user);
|
||||||
|
|
||||||
|
$this->storage = \OC\Files\Filesystem::getStorage('/');
|
||||||
\OC\Files\Filesystem::tearDown();
|
\OC\Files\Filesystem::tearDown();
|
||||||
\OC_User::setUserId($this->user);
|
\OC_User::setUserId($this->user);
|
||||||
\OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files');
|
\OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files');
|
||||||
|
@ -25,7 +33,7 @@ class Test_Helper_Storage extends PHPUnit_Framework_TestCase {
|
||||||
$this->storageMock = null;
|
$this->storageMock = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
protected function tearDown() {
|
||||||
$this->user = null;
|
$this->user = null;
|
||||||
|
|
||||||
if ($this->storageMock) {
|
if ($this->storageMock) {
|
||||||
|
@ -33,10 +41,13 @@ class Test_Helper_Storage extends PHPUnit_Framework_TestCase {
|
||||||
$this->storageMock = null;
|
$this->storageMock = null;
|
||||||
}
|
}
|
||||||
\OC\Files\Filesystem::tearDown();
|
\OC\Files\Filesystem::tearDown();
|
||||||
|
\OC\Files\Filesystem::mount($this->storage, array(), '/');
|
||||||
|
|
||||||
\OC_User::setUserId('');
|
\OC_User::setUserId('');
|
||||||
\OC_User::deleteUser($this->user);
|
\OC_User::deleteUser($this->user);
|
||||||
\OC_Preferences::deleteUser($this->user);
|
\OC_Preferences::deleteUser($this->user);
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,6 +11,28 @@ class Test_Migrate extends PHPUnit_Framework_TestCase {
|
||||||
public $users;
|
public $users;
|
||||||
public $tmpfiles = array();
|
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
|
* Generates a test user and sets up their file system
|
||||||
* @return string the test users id
|
* @return string the test users id
|
||||||
|
@ -73,18 +95,4 @@ class Test_Migrate extends PHPUnit_Framework_TestCase {
|
||||||
// Validate the export
|
// Validate the export
|
||||||
$this->validateUserExport($user2, $user, json_decode($export)->data);
|
$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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
class Preview extends \PHPUnit_Framework_TestCase {
|
class Preview extends \Test\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -20,14 +20,34 @@ class Preview extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
private $rootView;
|
private $rootView;
|
||||||
|
|
||||||
public function setUp() {
|
/** @var \OC\Files\Storage\Storage */
|
||||||
$this->user = $this->initFS();
|
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 = new \OC\Files\View('');
|
||||||
$this->rootView->mkdir('/'.$this->user);
|
$this->rootView->mkdir('/'.$this->user);
|
||||||
$this->rootView->mkdir('/'.$this->user.'/files');
|
$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() {
|
public function testIsPreviewDeleted() {
|
||||||
|
|
||||||
$sampleFile = '/'.$this->user.'/files/test.txt';
|
$sampleFile = '/'.$this->user.'/files/test.txt';
|
||||||
|
@ -184,16 +204,4 @@ class Preview extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals($this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/150-150.png', $isCached);
|
$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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,9 @@ class Test_StreamWrappers extends PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOC() {
|
public function testOC() {
|
||||||
|
$originalStorage = \OC\Files\Filesystem::getStorage('/');
|
||||||
\OC\Files\Filesystem::clearMounts();
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
|
||||||
$storage = new \OC\Files\Storage\Temporary(array());
|
$storage = new \OC\Files\Storage\Temporary(array());
|
||||||
$storage->file_put_contents('foo.txt', 'asd');
|
$storage->file_put_contents('foo.txt', 'asd');
|
||||||
\OC\Files\Filesystem::mount($storage, array(), '/');
|
\OC\Files\Filesystem::mount($storage, array(), '/');
|
||||||
|
@ -91,5 +93,8 @@ class Test_StreamWrappers extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
unlink('oc:///foo.txt');
|
unlink('oc:///foo.txt');
|
||||||
$this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
|
$this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
|
||||||
|
|
||||||
|
\OC\Files\Filesystem::clearMounts();
|
||||||
|
\OC\Files\Filesystem::mount($originalStorage, array(), '/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue