summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-07-07 18:38:58 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-07-08 11:32:06 +0200
commitdb65eeb5800745fb91cc2056e097c5988155ba20 (patch)
treeff85a4d6835c7e3bcb8a2090f0e2d4e754f71a84 /apps/files_trashbin/tests
parent0fe81d2f214c59dbe223e949232475fb8a6f24b9 (diff)
downloadnextcloud-server-db65eeb5800745fb91cc2056e097c5988155ba20.tar.gz
nextcloud-server-db65eeb5800745fb91cc2056e097c5988155ba20.zip
only move real files to the trash bin
Diffstat (limited to 'apps/files_trashbin/tests')
-rw-r--r--apps/files_trashbin/tests/storage.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/files_trashbin/tests/storage.php b/apps/files_trashbin/tests/storage.php
index 637543683dc..64540505d22 100644
--- a/apps/files_trashbin/tests/storage.php
+++ b/apps/files_trashbin/tests/storage.php
@@ -493,4 +493,34 @@ class Storage extends \Test\TestCase {
$results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
$this->assertEquals(0, count($results));
}
+
+ /**
+ * @dataProvider dataTestShouldMoveToTrash
+ */
+ public function testShouldMoveToTrash($mountPoint, $path, $userExists, $expected) {
+ $tmpStorage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
+ ->disableOriginalConstructor()->getMock();
+ $userManager = $this->getMockBuilder('OCP\IUserManager')
+ ->disableOriginalConstructor()->getMock();
+ $userManager->expects($this->any())
+ ->method('userExists')->willReturn($userExists);
+ $storage = new \OCA\Files_Trashbin\Storage(
+ ['mountPoint' => $mountPoint, 'storage' => $tmpStorage],
+ $userManager
+ );
+
+ $this->assertSame($expected,
+ $this->invokePrivate($storage, 'shouldMoveToTrash', [$path])
+ );
+
+ }
+
+ public function dataTestShouldMoveToTrash() {
+ return [
+ ['/schiesbn/', '/files/test.txt', true, true],
+ ['/schiesbn/', '/files/test.txt', false, false],
+ ['/schiesbn/', '/test.txt', true, false],
+ ['/schiesbn/', '/test.txt', false, false],
+ ];
+ }
}