Fixed getAbsolutePath case when path is "0"

Make sure to correctly check for string emptiness when the passed path
is "0".
remotes/origin/ldap_group_count
Vincent Petry 11 years ago
parent 6d00675d69
commit bab8c1f8e5
  1. 2
      lib/private/files/view.php
  2. 18
      tests/lib/files/view.php

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

@ -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'),
);
}
}

Loading…
Cancel
Save