diff options
author | Vincent Petry <pvince81@owncloud.com> | 2017-02-08 15:56:34 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-03-16 23:45:03 -0600 |
commit | 7256940524de24dc754678401e1902848bb5b175 (patch) | |
tree | f15246621756b3c19f34b686a2cdd05939da4c2f /tests/lib/Files | |
parent | 5683365a2cc605cbaf41290e4cdfde7028f9014a (diff) | |
download | nextcloud-server-7256940524de24dc754678401e1902848bb5b175.tar.gz nextcloud-server-7256940524de24dc754678401e1902848bb5b175.zip |
Redirect unlink to rmdir (#27101)
Many API callers will call unlink even for directories and it can mess
up with some wrappers like the encryption wrapper
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests/lib/Files')
-rw-r--r-- | tests/lib/Files/ViewTest.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 8ec9619087c..4cdea59da0d 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -515,6 +515,30 @@ class ViewTest extends \Test\TestCase { $this->assertFalse($rootView->file_exists('substorage/bar.txt')); } + public function rmdirOrUnlinkDataProvider() { + return [['rmdir'], ['unlink']]; + } + + /** + * @dataProvider rmdirOrUnlinkDataProvider + */ + public function testRmdir($method) { + $storage1 = $this->getTestStorage(); + $storage2 = $this->getTestStorage(); + Filesystem::mount($storage1, [], '/'); + + $rootView = new View(''); + $rootView->mkdir('sub'); + $rootView->mkdir('sub/deep'); + $rootView->file_put_contents('/sub/deep/foo.txt', 'asd'); + + $this->assertTrue($rootView->file_exists('sub/deep/foo.txt')); + + $this->assertTrue($rootView->$method('sub')); + + $this->assertFalse($rootView->file_exists('sub')); + } + /** * @medium */ |