Browse Source

bug: ConfigurationResolver - fix running without cache (#6915)

Kuba Werłos 1 year ago
parent
commit
97f65866e7

+ 2 - 1
src/Console/ConfigurationResolver.php

@@ -309,9 +309,10 @@ final class ConfigurationResolver
                 $absolutePath = $filesystem->isAbsolutePath($path)
                     ? $path
                     : $this->cwd.\DIRECTORY_SEPARATOR.$path;
+                $absolutePath = \dirname($absolutePath);
             }
 
-            $this->directory = new Directory(\dirname($absolutePath));
+            $this->directory = new Directory($absolutePath);
         }
 
         return $this->directory;

+ 1 - 1
tests/Console/ConfigurationResolverTest.php

@@ -1173,7 +1173,7 @@ For more info about updating see: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/b
     public static function provideGetDirectoryCases(): array
     {
         return [
-            [null, '/my/path/my/file', 'path/my/file'],
+            [null, '/my/path/my/file', 'my/file'],
             ['/my/path/.php-cs-fixer.cache', '/my/path/my/file', 'my/file'],
             ['/my/path2/dir/.php-cs-fixer.cache', '/my/path2/dir/dir2/file', 'dir2/file'],
             ['dir/.php-cs-fixer.cache', '/my/path/dir/dir3/file', 'dir3/file'],

+ 2 - 0
tests/Smoke/PharTest.php

@@ -103,6 +103,8 @@ final class PharTest extends AbstractSmokeTest
 
     public static function provideReportCases(): iterable
     {
+        yield ['no'];
+
         yield ['yes'];
     }
 

+ 1 - 2
tests/Smoke/StdinTest.php

@@ -59,9 +59,8 @@ final class StdinTest extends AbstractSmokeTest
         $fileResult = str_replace("\n--- ".$path."\n", "\n--- php://stdin\n", $fileResult);
         $fileResult = str_replace("\n+++ ".$path."\n", "\n+++ php://stdin\n", $fileResult);
 
-        $path = str_replace('/', \DIRECTORY_SEPARATOR, basename(realpath($cwd)).'/'.$inputFile);
         $fileResult = Preg::replace(
-            '#/?'.preg_quote($path, '#').'#',
+            '#/?'.preg_quote($inputFile, '#').'#',
             'php://stdin',
             $fileResult
         );