summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-01-23 18:08:59 +0100
committerVincent Petry <pvince81@owncloud.com>2015-01-23 18:08:59 +0100
commit1f39a7aabef951b1f737ad6dca81d848a7a8291a (patch)
treee523a453aec4878d900af3220f2aad67b77c26be /apps
parent1a06edd7125f6fb71b707fa2912012b74a209a62 (diff)
downloadnextcloud-server-1f39a7aabef951b1f737ad6dca81d848a7a8291a.tar.gz
nextcloud-server-1f39a7aabef951b1f737ad6dca81d848a7a8291a.zip
Simplify trash storage unit tests
Needed to make it properly init the mount points
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/tests/storage.php62
1 files changed, 16 insertions, 46 deletions
diff --git a/apps/files_trashbin/tests/storage.php b/apps/files_trashbin/tests/storage.php
index c340b9d2362..bd58395306b 100644
--- a/apps/files_trashbin/tests/storage.php
+++ b/apps/files_trashbin/tests/storage.php
@@ -20,11 +20,6 @@ class Storage extends \Test\TestCase {
private $wrapper;
/**
- * @var \OCP\Files\Storage
- */
- private $storage;
-
- /**
* @var string
*/
private $user;
@@ -37,6 +32,11 @@ class Storage extends \Test\TestCase {
/**
* @var \OC\Files\View
*/
+ private $rootView;
+
+ /**
+ * @var \OC\Files\View
+ */
private $userView;
protected function setUp() {
@@ -50,52 +50,31 @@ class Storage extends \Test\TestCase {
$this->originalStorage = \OC\Files\Filesystem::getStorage('/');
- $mockUser = $this->getMock('\OCP\IUser');
- $mockUser->expects($this->any())
- ->method('getHome')
- ->will($this->returnValue($this->originalStorage->getLocalFolder($this->user)));
- $mockUser->expects($this->any())
- ->method('getUID')
- ->will($this->returnValue($this->user));
-
- // use temp as root storage so we can wrap it for testing
- $this->storage = new Home(
- array('user' => $mockUser)
- );
- $this->wrapper = new \OCA\Files_Trashbin\Storage(
- array(
- 'storage' => $this->storage,
- 'mountPoint' => $this->user,
- )
- );
-
- // make room for a new root
- Filesystem::clearMounts();
- $rootMount = new MountPoint($this->originalStorage, '');
- Filesystem::getMountManager()->addMount($rootMount);
- $homeMount = new MountPoint($this->wrapper, $this->user);
- Filesystem::getMountManager()->addMount($homeMount);
+ \OCA\Files_Trashbin\Storage::setupStorage();
+ $this->rootView = new \OC\Files\View('/');
$this->userView = new \OC\Files\View('/' . $this->user . '/files/');
$this->userView->file_put_contents('test.txt', 'foo');
+
}
protected function tearDown() {
+ \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
$this->logout();
+ \OC_User::deleteUser($this->user);
parent::tearDown();
}
public function testSingleStorageDelete() {
- $this->assertTrue($this->storage->file_exists('files/test.txt'));
+ $this->assertTrue($this->userView->file_exists('test.txt'));
$this->userView->unlink('test.txt');
- $this->storage->getScanner()->scan('');
+ list($storage, ) = $this->userView->resolvePath('test.txt');
+ $storage->getScanner()->scan(''); // make sure we check the storage
$this->assertFalse($this->userView->getFileInfo('test.txt'));
- $this->assertFalse($this->storage->file_exists('files/test.txt'));
// check if file is in trashbin
- $rootView = new \OC\Files\View('/');
- $results = $rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
+ $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
$this->assertEquals(1, count($results));
$name = $results[0]->getName();
$this->assertEquals('test.txt', substr($name, 0, strrpos($name, '.')));
@@ -103,15 +82,7 @@ class Storage extends \Test\TestCase {
public function testCrossStorageDelete() {
$storage2 = new Temporary(array());
- $wrapper2 = new \OCA\Files_Trashbin\Storage(
- array(
- 'storage' => $storage2,
- 'mountPoint' => $this->user . '/files/substorage',
- )
- );
-
- $mount = new MountPoint($wrapper2, $this->user . '/files/substorage');
- Filesystem::getMountManager()->addMount($mount);
+ \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage');
$this->userView->file_put_contents('substorage/subfile.txt', 'foo');
$storage2->getScanner()->scan('');
@@ -123,8 +94,7 @@ class Storage extends \Test\TestCase {
$this->assertFalse($storage2->file_exists('subfile.txt'));
// check if file is in trashbin
- $rootView = new \OC\Files\View('/');
- $results = $rootView->getDirectoryContent($this->user . '/files_trashbin/files');
+ $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
$this->assertEquals(1, count($results));
$name = $results[0]->getName();
$this->assertEquals('subfile.txt', substr($name, 0, strrpos($name, '.')));