summaryrefslogtreecommitdiffstats
path: root/tests/lib/preview.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-11-12 15:54:41 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-11-17 10:48:19 +0100
commit6625d5c88f74edade459ec7e2ee0bfb79f21fedd (patch)
treec615a82f5838b8ebded306c4c474751d2f2e782a /tests/lib/preview.php
parent289a27778e78bb69830b5b05f4084627a781157b (diff)
downloadnextcloud-server-6625d5c88f74edade459ec7e2ee0bfb79f21fedd.tar.gz
nextcloud-server-6625d5c88f74edade459ec7e2ee0bfb79f21fedd.zip
Correctly restore previous root mount point after testing
Diffstat (limited to 'tests/lib/preview.php')
-rw-r--r--tests/lib/preview.php38
1 files changed, 23 insertions, 15 deletions
diff --git a/tests/lib/preview.php b/tests/lib/preview.php
index 2febe524cba..288dd2aa417 100644
--- a/tests/lib/preview.php
+++ b/tests/lib/preview.php
@@ -8,7 +8,7 @@
namespace Test;
-class Preview extends \PHPUnit_Framework_TestCase {
+class Preview extends \Test\TestCase {
/**
* @var string
@@ -20,14 +20,34 @@ class Preview extends \PHPUnit_Framework_TestCase {
*/
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';
@@ -184,16 +204,4 @@ class Preview extends \PHPUnit_Framework_TestCase {
$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;
- }
}