From 8c940699c1a1723222db3de2c2726a870e62013e Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Fri, 6 Apr 2012 23:16:46 +0100 Subject: [PATCH] [Filesystem] Added unit tests for isAbsolutePath method. --- .../Filesystem/Tests/FilesystemTest.php | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 367c83ea2e6a..d420a6310ccb 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -411,7 +411,7 @@ public function testSymlinkIsNotOverwrittenIfAlreadyCreated() } /** - * @dataProvider provideAbsolutePaths + * @dataProvider providePathsForMakePathRelative */ public function testMakePathRelative($endPath, $startPath, $expectedPath) { @@ -423,7 +423,7 @@ public function testMakePathRelative($endPath, $startPath, $expectedPath) /** * @return array */ - public function provideAbsolutePaths() + public function providePathsForMakePathRelative() { $paths = array( array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component', '../'), @@ -441,6 +441,30 @@ public function provideAbsolutePaths() return $paths; } + /** + * @dataProvider providePathsForIsAbsolutePath + */ + public function testIsAbsolutePath($path, $expectedResult) + { + $result = $this->filesystem->isAbsolutePath($path); + + $this->assertEquals($expectedResult, $result); + } + + /** + * @return array + */ + public function providePathsForIsAbsolutePath() + { + return array( + array('/var/lib', true), + array('c:\\\\var\\lib', true), + array('\\var\\lib', true), + array('var/lib', false), + array('../var/lib', false) + ); + } + /** * Returns file permissions as three digits (i.e. 755) *