Fix test & behavior
parent
5d9cb3eb4b
commit
edf93f1fcc
|
@ -66,11 +66,12 @@ class Filesystem
|
||||||
throw new \InvalidArgumentException('from and to must be absolute paths');
|
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)) {
|
if (dirname($from) === dirname($to)) {
|
||||||
return './'.basename($to);
|
return './'.basename($to);
|
||||||
}
|
}
|
||||||
$from = lcfirst(rtrim(strtr($from, '\\', '/'), '/'));
|
|
||||||
$to = lcfirst(rtrim(strtr($to, '\\', '/'), '/'));
|
|
||||||
|
|
||||||
$commonPath = $to;
|
$commonPath = $to;
|
||||||
while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
|
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');
|
throw new \InvalidArgumentException('from and to must be absolute paths');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$from = lcfirst(strtr($from, '\\', '/'));
|
||||||
|
$to = lcfirst(strtr($to, '\\', '/'));
|
||||||
|
|
||||||
if ($from === $to) {
|
if ($from === $to) {
|
||||||
return $directories ? '__DIR__' : '__FILE__';
|
return $directories ? '__DIR__' : '__FILE__';
|
||||||
}
|
}
|
||||||
$from = lcfirst(strtr($from, '\\', '/'));
|
|
||||||
$to = lcfirst(strtr($to, '\\', '/'));
|
|
||||||
|
|
||||||
$commonPath = $to;
|
$commonPath = $to;
|
||||||
while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
|
while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
// autoload_namespace.php generated by Composer
|
// autoload_namespace.php generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
$vendorDir = dirname(__DIR__);
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = $vendorDir;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Main' => $vendorDir . '/src/',
|
'Main' => $baseDir . '/src/',
|
||||||
'Lala' => $vendorDir . '/src/',
|
'Lala' => $baseDir . '/src/',
|
||||||
);
|
);
|
||||||
|
|
|
@ -41,6 +41,8 @@ class FilesystemTest extends TestCase
|
||||||
array('/foo/bar', '/foo/baz', true, "dirname(__DIR__).'/baz'"),
|
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', '/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('/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', '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'"),
|
array('c:/bin/run', 'd:/vendor/acme/bin/run', true, "'d:/vendor/acme/bin/run'"),
|
||||||
|
|
Loading…
Reference in New Issue