Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-05-20 19:31:32 +0300
committerVincent Petry <pvince81@owncloud.com>2015-09-22 12:34:37 +0300
commitb9cd5bc1dc3c68701804013f218b7866621a8d40 (patch)
treea27b049150d102663c9b174f78c661cdebd9e2e1 /tests
parent67231ed9a75eafe5b417e4525e3d80b1a3f8826b (diff)
Prevent wrong matches in getRelativePath
Before this fix, the root "/files" with path "/files_trashbin" would return "_trashbin" as relative path...
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/view.php27
1 files changed, 17 insertions, 10 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index bb42f385fc5..dd099674e62 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -853,22 +853,29 @@ class View extends \Test\TestCase {
/**
* @dataProvider relativePathProvider
*/
- function testGetRelativePath($absolutePath, $expectedPath) {
+ function testGetRelativePath($root, $absolutePath, $expectedPath) {
$view = new \OC\Files\View('/files');
- // simulate a external storage mount point which has a trailing slash
- $view->chroot('/files/');
+ $view->chroot($root);
$this->assertEquals($expectedPath, $view->getRelativePath($absolutePath));
}
function relativePathProvider() {
return array(
- array('/files/', '/'),
- array('/files', '/'),
- array('/files/0', '0'),
- array('/files/false', 'false'),
- array('/files/true', 'true'),
- array('/files/test', 'test'),
- array('/files/test/foo', 'test/foo'),
+ // TODO: add many more cases with mixed slashes, which is only possible
+ // once getRelativePath's behavior is made consistent
+
+ // with slashes
+ array('/files/', '/files/', '/'),
+ array('/files/', '/files', '/'),
+ array('/files/', '/files/0', '0'),
+ array('/files/', '/files/false', 'false'),
+ array('/files/', '/files/true', 'true'),
+ array('/files/', '/files/test', 'test'),
+ array('/files/', '/files/test/foo', 'test/foo'),
+ // mix
+ array('files', 'files_trashbin/test', null),
+ array('/files', '/files_trashbin/test', null),
+ array('/files', 'files_trashbin/test', null),
);
}