From db65eeb5800745fb91cc2056e097c5988155ba20 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 7 Jul 2015 18:38:58 +0200 Subject: only move real files to the trash bin --- apps/files_trashbin/tests/storage.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'apps/files_trashbin/tests') 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], + ]; + } } -- cgit v1.2.3