Преглед на файлове

Fix __DIR__/getcwd() inconsistency.

AnrDaemon преди 8 години
родител
ревизия
810e70d234
променени са 1 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 6 2
      tests/Composer/Test/Repository/PathRepositoryTest.php

+ 6 - 2
tests/Composer/Test/Repository/PathRepositoryTest.php

@@ -96,8 +96,12 @@ class PathRepositoryTest extends TestCase
         $loader = new ArrayLoader(new VersionParser());
         $versionGuesser = null;
 
-        $repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', 'with-version'));
-        $relativeUrl = ltrim(substr($repositoryUrl, strlen(getcwd())), DIRECTORY_SEPARATOR);
+        // realpath() does not fully expand the paths
+        // PHP Bug https://bugs.php.net/bug.php?id=72642
+        $repositoryUrl = implode(DIRECTORY_SEPARATOR, array(realpath(realpath(__DIR__)), 'Fixtures', 'path', 'with-version'));
+        // getcwd() not necessarily match __DIR__
+        // PHP Bug https://bugs.php.net/bug.php?id=73797
+        $relativeUrl = ltrim(substr($repositoryUrl, strlen(realpath(realpath(getcwd())))), DIRECTORY_SEPARATOR);
 
         $repository = new PathRepository(array('url' => $relativeUrl), $ioInterface, $config, $loader);
         $packages = $repository->getPackages();