1
0
Fork 0

Fix test & behavior

pull/422/head
Jordi Boggiano 2012-03-10 02:14:40 +01:00
parent 5d9cb3eb4b
commit edf93f1fcc
3 changed files with 11 additions and 7 deletions

View File

@ -66,11 +66,12 @@ class Filesystem
throw new \InvalidArgumentException('from and to must be absolute paths');
}
$from = lcfirst(rtrim(strtr($from, '\\', '/'), '/'));
$to = lcfirst(rtrim(strtr($to, '\\', '/'), '/'));
if (dirname($from) === dirname($to)) {
return './'.basename($to);
}
$from = lcfirst(rtrim(strtr($from, '\\', '/'), '/'));
$to = lcfirst(rtrim(strtr($to, '\\', '/'), '/'));
$commonPath = $to;
while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
@ -101,11 +102,12 @@ class Filesystem
throw new \InvalidArgumentException('from and to must be absolute paths');
}
$from = lcfirst(strtr($from, '\\', '/'));
$to = lcfirst(strtr($to, '\\', '/'));
if ($from === $to) {
return $directories ? '__DIR__' : '__FILE__';
}
$from = lcfirst(strtr($from, '\\', '/'));
$to = lcfirst(strtr($to, '\\', '/'));
$commonPath = $to;
while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {

View File

@ -3,9 +3,9 @@
// autoload_namespace.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
$baseDir = $vendorDir;
return array(
'Main' => $vendorDir . '/src/',
'Lala' => $vendorDir . '/src/',
'Main' => $baseDir . '/src/',
'Lala' => $baseDir . '/src/',
);

View File

@ -41,6 +41,8 @@ class FilesystemTest extends TestCase
array('/foo/bar', '/foo/baz', true, "dirname(__DIR__).'/baz'"),
array('/foo/bin/run', '/foo/vendor/acme/bin/run', true, "dirname(dirname(__DIR__)).'/vendor/acme/bin/run'"),
array('/foo/bin/run', '/bar/bin/run', true, "'/bar/bin/run'"),
array('/bin/run', '/bin/run', true, "__DIR__"),
array('c:/bin/run', 'c:\\bin/run', true, "__DIR__"),
array('c:/bin/run', 'c:/vendor/acme/bin/run', true, "dirname(dirname(__DIR__)).'/vendor/acme/bin/run'"),
array('c:\\bin\\run', 'c:/vendor/acme/bin/run', true, "dirname(dirname(__DIR__)).'/vendor/acme/bin/run'"),
array('c:/bin/run', 'd:/vendor/acme/bin/run', true, "'d:/vendor/acme/bin/run'"),