diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-11-12 15:54:41 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-11-17 10:48:19 +0100 |
commit | 6625d5c88f74edade459ec7e2ee0bfb79f21fedd (patch) | |
tree | c615a82f5838b8ebded306c4c474751d2f2e782a /tests/lib/files/cache | |
parent | 289a27778e78bb69830b5b05f4084627a781157b (diff) | |
download | nextcloud-server-6625d5c88f74edade459ec7e2ee0bfb79f21fedd.tar.gz nextcloud-server-6625d5c88f74edade459ec7e2ee0bfb79f21fedd.zip |
Correctly restore previous root mount point after testing
Diffstat (limited to 'tests/lib/files/cache')
-rw-r--r-- | tests/lib/files/cache/updater.php | 15 | ||||
-rw-r--r-- | tests/lib/files/cache/updaterlegacy.php | 9 | ||||
-rw-r--r-- | tests/lib/files/cache/watcher.php | 15 |
3 files changed, 34 insertions, 5 deletions
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php index 96b4207ad43..9e7330db20c 100644 --- a/tests/lib/files/cache/updater.php +++ b/tests/lib/files/cache/updater.php @@ -33,7 +33,13 @@ class Updater extends \PHPUnit_Framework_TestCase { */ 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(), '/'); @@ -42,6 +48,13 @@ class Updater extends \PHPUnit_Framework_TestCase { $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')); diff --git a/tests/lib/files/cache/updaterlegacy.php b/tests/lib/files/cache/updaterlegacy.php index c80c3168ad6..d16a062fcca 100644 --- a/tests/lib/files/cache/updaterlegacy.php +++ b/tests/lib/files/cache/updaterlegacy.php @@ -29,6 +29,9 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase { */ private $cache; + /** @var \OC\Files\Storage\Storage */ + private $originalStorage; + private static $user; public function setUp() { @@ -51,7 +54,8 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase { $this->scanner->scan(''); $this->cache = $this->storage->getCache(); - \OC\Files\Filesystem::tearDown(); + $this->originalStorage = Filesystem::getStorage('/'); + Filesystem::tearDown(); if (!self::$user) { self::$user = uniqid(); } @@ -59,7 +63,7 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase { \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'); @@ -74,6 +78,7 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase { $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'); diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php index 22c11b9a4e0..0b04b9e7058 100644 --- a/tests/lib/files/cache/watcher.php +++ b/tests/lib/files/cache/watcher.php @@ -15,16 +15,27 @@ class Watcher extends \PHPUnit_Framework_TestCase { */ 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(); } /** |