Fixed getAbsolutePath case when path is "0"

Make sure to correctly check for string emptiness when the passed path
is "0".

Backport of bab8c1f from master
This commit is contained in:
Vincent Petry 2014-05-13 14:17:51 +02:00
parent 1e6b4576c2
commit 0c355cb1fb
2 changed files with 19 additions and 1 deletions

View file

@ -35,7 +35,7 @@ class View {
}
public function getAbsolutePath($path = '/') {
if (!$path) {
if ($path === '') {
$path = '/';
}
if ($path[0] !== '/') {

View file

@ -578,4 +578,22 @@ class View extends \PHPUnit_Framework_TestCase {
$info2 = $view->getFileInfo('/test/test');
$this->assertEquals($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'),
);
}
}