]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed getAbsolutePath case when path is "0"
authorVincent Petry <pvince81@owncloud.com>
Tue, 13 May 2014 12:17:51 +0000 (14:17 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 13 May 2014 15:38:46 +0000 (17:38 +0200)
Make sure to correctly check for string emptiness when the passed path
is "0".

lib/private/files/view.php
tests/lib/files/view.php

index 407f598195752b0a640d39400125c1a7a4cd56ef..39c71cfc0b01e9afa91c1393e536960f1f83427d 100644 (file)
@@ -37,7 +37,7 @@ class View {
        }
 
        public function getAbsolutePath($path = '/') {
-               if (!$path) {
+               if ($path === '') {
                        $path = '/';
                }
                if ($path[0] !== '/') {
index f80dd06e1cb6a097c7c3aace88ce3e105cd0b7f4..a51b15857d5393f75a31ac724e92cfc94f9dccab 100644 (file)
@@ -585,4 +585,22 @@ class View extends \PHPUnit_Framework_TestCase {
                $info2 = $view->getFileInfo('/test/test');
                $this->assertSame($info['etag'], $info2['etag']);
        }
+
+       /**
+        * @dataProvider absolutePathProvider
+        */
+       public function testGetAbsolutePath($expectedPath, $relativePath) {
+               $view = new \OC\Files\View('/files');
+               $this->assertEquals($expectedPath, $view->getAbsolutePath($relativePath));
+       }
+
+       function absolutePathProvider() {
+               return array(
+                       array('/files/', ''),
+                       array('/files/0', '0'),
+                       array('/files/', '/'),
+                       array('/files/test', 'test'),
+                       array('/files/test', '/test'),
+               );
+       }
 }