From 4f0f8779cb6db67d2186e3480f5ca2243e9916e5 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 11 Apr 2016 19:36:39 +0100 Subject: [PATCH] Add filesystem tests for the static shortest path, refs #5174 --- tests/Composer/Test/Util/FilesystemTest.php | 28 ++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index 550b0e3ce..17297b916 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -32,15 +32,6 @@ class FilesystemTest extends TestCase */ private $testFile; - /** - * @dataProvider providePathCouplesAsCode - */ - public function testFindShortestPathCode($a, $b, $directory, $expected) - { - $fs = new Filesystem; - $this->assertEquals($expected, $fs->findShortestPathCode($a, $b, $directory)); - } - public function setUp() { $this->fs = new Filesystem; @@ -58,6 +49,15 @@ class FilesystemTest extends TestCase } } + /** + * @dataProvider providePathCouplesAsCode + */ + public function testFindShortestPathCode($a, $b, $directory, $expected, $static = false) + { + $fs = new Filesystem; + $this->assertEquals($expected, $fs->findShortestPathCode($a, $b, $directory, $static)); + } + public function providePathCouplesAsCode() { return array( @@ -94,6 +94,16 @@ class FilesystemTest extends TestCase array('/foo/bar_vendor', '/foo/bar', true, "dirname(__DIR__).'/bar'"), array('/foo/bar_vendor', '/foo/bar/src', true, "dirname(__DIR__).'/bar/src'"), array('/foo/bar_vendor/src2', '/foo/bar/src/lib', true, "dirname(dirname(__DIR__)).'/bar/src/lib'"), + + // static use case + array('/tmp/test/../vendor', '/tmp/test', true, "__DIR__ . '/..'.'/test'", true), + array('/tmp/test/.././vendor', '/tmp/test', true, "__DIR__ . '/..'.'/test'", true), + array('C:/Temp', 'c:\Temp\..\..\test', true, "__DIR__ . '/..'.'/test'", true), + array('C:/Temp/../..', 'd:\Temp\..\..\test', true, "'d:/test'", true), + array('/foo/bar', '/foo/bar_vendor', true, "__DIR__ . '/..'.'/bar_vendor'", true), + array('/foo/bar_vendor', '/foo/bar', true, "__DIR__ . '/..'.'/bar'", true), + array('/foo/bar_vendor', '/foo/bar/src', true, "__DIR__ . '/..'.'/bar/src'", true), + array('/foo/bar_vendor/src2', '/foo/bar/src/lib', true, "__DIR__ . '/../..'.'/bar/src/lib'", true), ); }