diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-11-07 15:23:15 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-11-19 14:52:07 +0100 |
commit | bb540722cd4e197bd608d9a87e4b10cf66dec5a9 (patch) | |
tree | f243bae56944c4b88b2545941a6c6de1e7321f04 /tests/lib/files | |
parent | 284ba5b688d7f0a9d2e1f7b9a68a7e8362be5e67 (diff) | |
download | nextcloud-server-bb540722cd4e197bd608d9a87e4b10cf66dec5a9.tar.gz nextcloud-server-bb540722cd4e197bd608d9a87e4b10cf66dec5a9.zip |
Use base class to reset the file mapper
Diffstat (limited to 'tests/lib/files')
29 files changed, 106 insertions, 56 deletions
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php index 969740419c6..02c45a16571 100644 --- a/tests/lib/files/cache/cache.php +++ b/tests/lib/files/cache/cache.php @@ -16,7 +16,7 @@ class LongId extends \OC\Files\Storage\Temporary { } } -class Cache extends \PHPUnit_Framework_TestCase { +class Cache extends \Test\TestCase { /** * @var \OC\Files\Storage\Temporary $storage ; */ @@ -452,13 +452,17 @@ class Cache extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($this->cache->getFolderContents('folder'))); } - public function tearDown() { + protected function tearDown() { if ($this->cache) { $this->cache->clear(); } + + parent::tearDown(); } - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->storage = new \OC\Files\Storage\Temporary(array()); $this->storage2 = new \OC\Files\Storage\Temporary(array()); $this->cache = new \OC\Files\Cache\Cache($this->storage); diff --git a/tests/lib/files/cache/changepropagator.php b/tests/lib/files/cache/changepropagator.php index a52682cd086..89bd9dfe80a 100644 --- a/tests/lib/files/cache/changepropagator.php +++ b/tests/lib/files/cache/changepropagator.php @@ -12,7 +12,7 @@ use OC\Files\Filesystem; use OC\Files\Storage\Temporary; use OC\Files\View; -class ChangePropagator extends \PHPUnit_Framework_TestCase { +class ChangePropagator extends \Test\TestCase { /** * @var \OC\Files\Cache\ChangePropagator */ @@ -23,9 +23,11 @@ class ChangePropagator extends \PHPUnit_Framework_TestCase { */ private $view; - public function setUp() { + protected function setUp() { + parent::setUp(); + $storage = new Temporary(array()); - $root = '/' . uniqid(); + $root = $this->getUniqueID('/'); Filesystem::mount($storage, array(), $root); $this->view = new View($root); $this->propagator = new \OC\Files\Cache\ChangePropagator($this->view); diff --git a/tests/lib/files/cache/homecache.php b/tests/lib/files/cache/homecache.php index 80dc54c9d19..7ebb053bcfa 100644 --- a/tests/lib/files/cache/homecache.php +++ b/tests/lib/files/cache/homecache.php @@ -43,7 +43,7 @@ class DummyUser extends \OC\User\User { } } -class HomeCache extends \PHPUnit_Framework_TestCase { +class HomeCache extends \Test\TestCase { /** * @var \OC\Files\Storage\Home $storage */ @@ -59,7 +59,9 @@ class HomeCache extends \PHPUnit_Framework_TestCase { */ private $user; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->user = new DummyUser('foo', \OC_Helper::tmpFolder()); $this->storage = new \OC\Files\Storage\Home(array('user' => $this->user)); $this->cache = $this->storage->getCache(); diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php index 0a274631d1c..b44cf0a49df 100644 --- a/tests/lib/files/cache/scanner.php +++ b/tests/lib/files/cache/scanner.php @@ -8,7 +8,7 @@ namespace Test\Files\Cache; -class Scanner extends \PHPUnit_Framework_TestCase { +class Scanner extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage $storage */ @@ -24,16 +24,20 @@ class Scanner extends \PHPUnit_Framework_TestCase { */ private $cache; - function setUp() { + protected function setUp() { + parent::setUp(); + $this->storage = new \OC\Files\Storage\Temporary(array()); $this->scanner = new \OC\Files\Cache\Scanner($this->storage); $this->cache = new \OC\Files\Cache\Cache($this->storage); } - function tearDown() { + protected function tearDown() { if ($this->cache) { $this->cache->clear(); } + + parent::tearDown(); } function testFile() { diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php index 9e7330db20c..01b036de5d8 100644 --- a/tests/lib/files/cache/updater.php +++ b/tests/lib/files/cache/updater.php @@ -12,7 +12,7 @@ use OC\Files\Filesystem; use OC\Files\Storage\Temporary; use OC\Files\View; -class Updater extends \PHPUnit_Framework_TestCase { +class Updater extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage */ @@ -40,6 +40,7 @@ class Updater extends \PHPUnit_Framework_TestCase { parent::setUp(); $this->originalStorage = Filesystem::getStorage('/'); + $this->storage = new Temporary(array()); Filesystem::clearMounts(); Filesystem::mount($this->storage, array(), '/'); diff --git a/tests/lib/files/cache/updaterlegacy.php b/tests/lib/files/cache/updaterlegacy.php index d16a062fcca..7c05800cd6b 100644 --- a/tests/lib/files/cache/updaterlegacy.php +++ b/tests/lib/files/cache/updaterlegacy.php @@ -11,7 +11,7 @@ namespace Test\Files\Cache; use \OC\Files\Filesystem as Filesystem; use OC\Files\Storage\Temporary; -class UpdaterLegacy extends \PHPUnit_Framework_TestCase { +class UpdaterLegacy extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage $storage */ @@ -34,7 +34,8 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase { private static $user; - public function setUp() { + protected function setUp() { + parent::setUp(); // remember files_encryption state $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption'); @@ -71,7 +72,7 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase { \OC_Hook::clear('OC_Filesystem'); } - public function tearDown() { + protected function tearDown() { if ($this->cache) { $this->cache->clear(); } @@ -83,6 +84,8 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase { if ($this->stateFilesEncryption) { \OC_App::enable('files_encryption'); } + + parent::tearDown(); } public function testWrite() { diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php index 0b04b9e7058..ee605c64e01 100644 --- a/tests/lib/files/cache/watcher.php +++ b/tests/lib/files/cache/watcher.php @@ -8,7 +8,7 @@ namespace Test\Files\Cache; -class Watcher extends \PHPUnit_Framework_TestCase { +class Watcher extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage[] $storages diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php index 8f29ed0bc63..eec24d9f4c6 100644 --- a/tests/lib/files/etagtest.php +++ b/tests/lib/files/etagtest.php @@ -56,7 +56,7 @@ class EtagTest extends \Test\TestCase { } public function testNewUser() { - $user1 = uniqid('user_'); + $user1 = $this->getUniqueID('user_'); $this->userBackend->createUser($user1, ''); \OC_Util::tearDownFS(); diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index f24d86b212d..746600c7d15 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -55,6 +55,8 @@ class Filesystem extends \Test\TestCase { \OC\Files\Filesystem::clearMounts(); \OC\Files\Filesystem::mount($this->originalStorage, array(), '/'); \OC_User::setUserId(''); + + parent::tearDown(); } public function testMount() { diff --git a/tests/lib/files/mapper.php b/tests/lib/files/mapper.php index d513f3ce4b3..18161734b60 100644 --- a/tests/lib/files/mapper.php +++ b/tests/lib/files/mapper.php @@ -22,14 +22,15 @@ namespace Test\Files; -class Mapper extends \PHPUnit_Framework_TestCase { +class Mapper extends \Test\TestCase { /** * @var \OC\Files\Mapper */ private $mapper = null; - public function setUp() { + protected function setUp() { + parent::setUp(); $this->mapper = new \OC\Files\Mapper('D:/'); } diff --git a/tests/lib/files/mount/manager.php b/tests/lib/files/mount/manager.php index 154c35ccead..051b76ccf2e 100644 --- a/tests/lib/files/mount/manager.php +++ b/tests/lib/files/mount/manager.php @@ -16,13 +16,14 @@ class LongId extends Temporary { } } -class Manager extends \PHPUnit_Framework_TestCase { +class Manager extends \Test\TestCase { /** * @var \OC\Files\Mount\Manager */ private $manager; - public function setup() { + protected function setup() { + parent::setUp(); $this->manager = new \OC\Files\Mount\Manager(); } diff --git a/tests/lib/files/mount/mount.php b/tests/lib/files/mount/mount.php index c3d33e0870b..5ee3d934e97 100644 --- a/tests/lib/files/mount/mount.php +++ b/tests/lib/files/mount/mount.php @@ -12,7 +12,7 @@ namespace Test\Files\Mount; use OC\Files\Storage\Loader; use OC\Files\Storage\Wrapper\Wrapper; -class Mount extends \PHPUnit_Framework_TestCase { +class Mount extends \Test\TestCase { public function testFromStorageObject() { $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') ->disableOriginalConstructor() diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php index 76938a0dcc8..34ec7dee213 100644 --- a/tests/lib/files/node/file.php +++ b/tests/lib/files/node/file.php @@ -12,10 +12,11 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OC\Files\View; -class File extends \PHPUnit_Framework_TestCase { +class File extends \Test\TestCase { private $user; - public function setUp() { + protected function setUp() { + parent::setUp(); $this->user = new \OC\User\User('', new \OC_User_Dummy); } diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php index 436161aba72..e348e452f6f 100644 --- a/tests/lib/files/node/folder.php +++ b/tests/lib/files/node/folder.php @@ -15,10 +15,11 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OC\Files\View; -class Folder extends \PHPUnit_Framework_TestCase { +class Folder extends \Test\TestCase { private $user; - public function setUp() { + protected function setUp() { + parent::setUp(); $this->user = new \OC\User\User('', new \OC_User_Dummy); } diff --git a/tests/lib/files/node/integration.php b/tests/lib/files/node/integration.php index cde2eb22b7b..fd777460ec6 100644 --- a/tests/lib/files/node/integration.php +++ b/tests/lib/files/node/integration.php @@ -14,7 +14,7 @@ use OC\Files\Storage\Temporary; use OC\Files\View; use OC\User\User; -class IntegrationTests extends \PHPUnit_Framework_TestCase { +class IntegrationTests extends \Test\TestCase { /** * @var \OC\Files\Node\Root $root */ @@ -65,7 +65,6 @@ class IntegrationTests extends \PHPUnit_Framework_TestCase { $storage->getCache()->clear(); } \OC\Files\Filesystem::clearMounts(); - \OC\Files\Filesystem::mount($this->originalStorage, array(), '/'); parent::tearDown(); diff --git a/tests/lib/files/node/node.php b/tests/lib/files/node/node.php index cf5fec30522..80e3ac6f80a 100644 --- a/tests/lib/files/node/node.php +++ b/tests/lib/files/node/node.php @@ -8,10 +8,11 @@ namespace Test\Files\Node; -class Node extends \PHPUnit_Framework_TestCase { +class Node extends \Test\TestCase { private $user; - public function setUp() { + protected function setUp() { + parent::setUp(); $this->user = new \OC\User\User('', new \OC_User_Dummy); } diff --git a/tests/lib/files/node/root.php b/tests/lib/files/node/root.php index 27f1a937826..fcce7070f5d 100644 --- a/tests/lib/files/node/root.php +++ b/tests/lib/files/node/root.php @@ -11,10 +11,11 @@ namespace Test\Files\Node; use OCP\Files\NotPermittedException; use OC\Files\Mount\Manager; -class Root extends \PHPUnit_Framework_TestCase { +class Root extends \Test\TestCase { private $user; - public function setUp() { + protected function setUp() { + parent::setUp(); $this->user = new \OC\User\User('', new \OC_User_Dummy); } diff --git a/tests/lib/files/objectstore/swift.php b/tests/lib/files/objectstore/swift.php index 37d6cc74de6..f2c4a983cf2 100644 --- a/tests/lib/files/objectstore/swift.php +++ b/tests/lib/files/objectstore/swift.php @@ -30,7 +30,9 @@ class Swift extends \Test\Files\Storage\Storage { private $objectStorage; - public function setUp() { + protected function setUp() { + parent::setUp(); + if (!getenv('RUN_OBJECTSTORE_TESTS')) { $this->markTestSkipped('objectstore tests are unreliable on travis'); } @@ -74,12 +76,14 @@ class Swift extends \Test\Files\Storage\Storage { $this->instance = new ObjectStoreStorage($params); } - public function tearDown() { + protected function tearDown() { if (is_null($this->instance)) { return; } $this->objectStorage->deleteContainer(true); $this->instance->getCache()->clear(); + + parent::tearDown(); } public function testStat() { diff --git a/tests/lib/files/storage/commontest.php b/tests/lib/files/storage/commontest.php index ce53c884f32..2b70dc8713e 100644 --- a/tests/lib/files/storage/commontest.php +++ b/tests/lib/files/storage/commontest.php @@ -27,12 +27,15 @@ class CommonTest extends Storage { * @var string tmpDir */ private $tmpDir; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->tmpDir=\OC_Helper::tmpFolder(); $this->instance=new \OC\Files\Storage\CommonTest(array('datadir'=>$this->tmpDir)); } - public function tearDown() { + protected function tearDown() { \OC_Helper::rmdirr($this->tmpDir); + parent::tearDown(); } } diff --git a/tests/lib/files/storage/home.php b/tests/lib/files/storage/home.php index d085efe9c1c..b0670a22892 100644 --- a/tests/lib/files/storage/home.php +++ b/tests/lib/files/storage/home.php @@ -60,15 +60,18 @@ class Home extends Storage { */ private $user; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->tmpDir = \OC_Helper::tmpFolder(); - $this->userId = uniqid('user_'); + $this->userId = $this->getUniqueID('user_'); $this->user = new DummyUser($this->userId, $this->tmpDir); $this->instance = new \OC\Files\Storage\Home(array('user' => $this->user)); } - public function tearDown() { + protected function tearDown() { \OC_Helper::rmdirr($this->tmpDir); + parent::tearDown(); } /** diff --git a/tests/lib/files/storage/local.php b/tests/lib/files/storage/local.php index 490086c62f2..d2b27117c3b 100644 --- a/tests/lib/files/storage/local.php +++ b/tests/lib/files/storage/local.php @@ -28,13 +28,16 @@ class Local extends Storage { */ private $tmpDir; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->tmpDir = \OC_Helper::tmpFolder(); $this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); } - public function tearDown() { + protected function tearDown() { \OC_Helper::rmdirr($this->tmpDir); + parent::tearDown(); } public function testStableEtag() { diff --git a/tests/lib/files/storage/mappedlocal.php b/tests/lib/files/storage/mappedlocal.php index b483f3a1954..1e87b53d00a 100644 --- a/tests/lib/files/storage/mappedlocal.php +++ b/tests/lib/files/storage/mappedlocal.php @@ -27,14 +27,17 @@ class MappedLocal extends Storage { * @var string tmpDir */ private $tmpDir; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->tmpDir=\OC_Helper::tmpFolder(); $this->instance=new \OC\Files\Storage\MappedLocal(array('datadir'=>$this->tmpDir)); } - public function tearDown() { + protected function tearDown() { \OC_Helper::rmdirr($this->tmpDir); unset($this->instance); + parent::tearDown(); } } diff --git a/tests/lib/files/storage/mappedlocalwithdotteddatadir.php b/tests/lib/files/storage/mappedlocalwithdotteddatadir.php index d2e5e2e97af..3a733b7b469 100644 --- a/tests/lib/files/storage/mappedlocalwithdotteddatadir.php +++ b/tests/lib/files/storage/mappedlocalwithdotteddatadir.php @@ -28,15 +28,18 @@ class MappedLocalWithDottedDataDir extends Storage { */ private $tmpDir; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->tmpDir = \OC_Helper::tmpFolder().'dir.123'.DIRECTORY_SEPARATOR; mkdir($this->tmpDir); $this->instance=new \OC\Files\Storage\MappedLocal(array('datadir'=>$this->tmpDir)); } - public function tearDown() { + protected function tearDown() { \OC_Helper::rmdirr($this->tmpDir); unset($this->instance); + parent::tearDown(); } } diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php index 954fe199cc8..9e6b1c85a95 100644 --- a/tests/lib/files/storage/wrapper/quota.php +++ b/tests/lib/files/storage/wrapper/quota.php @@ -17,14 +17,17 @@ class Quota extends \Test\Files\Storage\Storage { */ private $tmpDir; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->tmpDir = \OC_Helper::tmpFolder(); $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); $this->instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 10000000)); } - public function tearDown() { + protected function tearDown() { \OC_Helper::rmdirr($this->tmpDir); + parent::tearDown(); } /** diff --git a/tests/lib/files/storage/wrapper/wrapper.php b/tests/lib/files/storage/wrapper/wrapper.php index 8bcf42035d4..486cd0495c1 100644 --- a/tests/lib/files/storage/wrapper/wrapper.php +++ b/tests/lib/files/storage/wrapper/wrapper.php @@ -14,14 +14,17 @@ class Wrapper extends \Test\Files\Storage\Storage { */ private $tmpDir; - public function setUp() { + protected function setUp() { + parent::setUp(); + $this->tmpDir = \OC_Helper::tmpFolder(); $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); $this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage)); } - public function tearDown() { + protected function tearDown() { \OC_Helper::rmdirr($this->tmpDir); + parent::tearDown(); } public function testInstanceOfStorageWrapper() { diff --git a/tests/lib/files/stream/quota.php b/tests/lib/files/stream/quota.php index d5edace544d..28584cf82db 100644 --- a/tests/lib/files/stream/quota.php +++ b/tests/lib/files/stream/quota.php @@ -8,9 +8,10 @@ namespace Test\Files\Stream; -class Quota extends \PHPUnit_Framework_TestCase { - public function tearDown() { +class Quota extends \Test\TestCase { + protected function tearDown() { \OC\Files\Stream\Quota::clear(); + parent::tearDown(); } /** diff --git a/tests/lib/files/stream/staticstream.php b/tests/lib/files/stream/staticstream.php index d55086196a0..416a4670efd 100644 --- a/tests/lib/files/stream/staticstream.php +++ b/tests/lib/files/stream/staticstream.php @@ -8,18 +8,20 @@ namespace Test\Files\Stream; -class StaticStream extends \PHPUnit_Framework_TestCase { +class StaticStream extends \Test\TestCase { private $sourceFile; private $sourceText; - public function __construct() { + protected function setUp() { + parent::setUp(); $this->sourceFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $this->sourceText = file_get_contents($this->sourceFile); } - public function tearDown() { + protected function tearDown() { \OC\Files\Stream\StaticStream::clear(); + parent::tearDown(); } public function testContent() { diff --git a/tests/lib/files/utils/scanner.php b/tests/lib/files/utils/scanner.php index db6a3fa7842..f729be81bd7 100644 --- a/tests/lib/files/utils/scanner.php +++ b/tests/lib/files/utils/scanner.php @@ -38,7 +38,6 @@ class TestScanner extends \OC\Files\Utils\Scanner { } } - class Scanner extends \Test\TestCase { /** @var \OC\Files\Storage\Storage */ private $originalStorage; diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 44fea65e64e..d6dd176bba9 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -16,7 +16,7 @@ class TemporaryNoTouch extends \OC\Files\Storage\Temporary { } } -class View extends \PHPUnit_Framework_TestCase { +class View extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage[] $storages */ |