summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/tests
diff options
context:
space:
mode:
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],
+ ];
+ }
}