From ccc100113803ec82fc2eab7c62620e2b3a4c7df6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 17 Nov 2014 16:57:15 +0100 Subject: [PATCH] Add tests for absolute paths on windows --- tests/lib/files/filesystem.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index 447c2717dbb..f24d86b212d 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -131,6 +131,14 @@ class Filesystem extends \Test\TestCase { array('/foo/.bar/', '\\foo\\.bar\\', false), array('/foo/.bar/tee', '\\foo\\.bar\\tee'), + // Absolute windows paths NOT marked as absolute + array('/C:', 'C:\\'), + array('/C:/', 'C:\\', false), + array('/C:/tests', 'C:\\tests'), + array('/C:/tests', 'C:\\tests', false), + array('/C:/tests', 'C:\\tests\\'), + array('/C:/tests/', 'C:\\tests\\', false), + // normalize does not resolve '..' (by design) array('/foo/..', '/foo/../'), array('/foo/..', '\\foo\\..\\'), @@ -140,8 +148,30 @@ class Filesystem extends \Test\TestCase { /** * @dataProvider normalizePathData */ - public function testNormalizePath($expected, $path, $stripTrailingSlash = true, $isAbsolutePath = false) { - $this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash, $isAbsolutePath)); + public function testNormalizePath($expected, $path, $stripTrailingSlash = true) { + $this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash)); + } + + public function normalizePathWindowsAbsolutePathData() { + return array( + array('C:/', 'C:\\'), + array('C:/', 'C:\\', false), + array('C:/tests', 'C:\\tests'), + array('C:/tests', 'C:\\tests', false), + array('C:/tests', 'C:\\tests\\'), + array('C:/tests/', 'C:\\tests\\', false), + ); + } + + /** + * @dataProvider normalizePathWindowsAbsolutePathData + */ + public function testNormalizePathWindowsAbsolutePath($expected, $path, $stripTrailingSlash = true) { + if (!\OC_Util::runningOnWindows()) { + $this->markTestSkipped('This test is Windows only'); + } + + $this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash, true)); } public function testNormalizePathUTF8() { -- 2.39.5