Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ee4b88

Browse filesBrowse files
committed
[Filesystem] Added unit tests for makePathRelative method.
1 parent 21860cb commit 2ee4b88
Copy full SHA for 2ee4b88

File tree

1 file changed

+31
-0
lines changed
Filter options

1 file changed

+31
-0
lines changed

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,37 @@ public function testSymlinkIsNotOverwrittenIfAlreadyCreated()
410410
$this->assertEquals($file, readlink($link));
411411
}
412412

413+
/**
414+
* @dataProvider provideAbsolutePaths
415+
*/
416+
public function testMakePathRelative($endPath, $startPath, $expectedPath)
417+
{
418+
$path = $this->filesystem->makePathRelative($endPath, $startPath);
419+
420+
$this->assertEquals($expectedPath, $path);
421+
}
422+
423+
/**
424+
* @return array
425+
*/
426+
public function provideAbsolutePaths()
427+
{
428+
$paths = array(
429+
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component', '../'),
430+
array('var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../'),
431+
array('/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/')
432+
);
433+
434+
// fix directory separator
435+
foreach ($paths as $i => $pathItems) {
436+
foreach ($pathItems as $k => $path) {
437+
$paths[$i][$k] = str_replace('/', DIRECTORY_SEPARATOR, $path);
438+
}
439+
}
440+
441+
return $paths;
442+
}
443+
413444
/**
414445
* Returns file permissions as three digits (i.e. 755)
415446
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.