Browse Source

Fix STDIN test when path is one level deep

Julien Falque 3 years ago
parent
commit
d33c35614b
1 changed files with 7 additions and 1 deletions
  1. 7 1
      tests/Smoke/StdinTest.php

+ 7 - 1
tests/Smoke/StdinTest.php

@@ -15,6 +15,7 @@ declare(strict_types=1);
 namespace PhpCsFixer\Tests\Smoke;
 
 use Keradus\CliExecutor\CommandExecutor;
+use PhpCsFixer\Preg;
 
 /**
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
@@ -45,6 +46,7 @@ final class StdinTest extends AbstractSmokeTest
             '',
             $fileResult->getError()
         );
+
         static::assertSame($expectedError, $stdinResult->getError());
 
         $fileResult = $this->unifyFooter($fileResult->getOutput());
@@ -55,7 +57,11 @@ final class StdinTest extends AbstractSmokeTest
         $fileResult = str_replace("\n+++ ".$path."\n", "\n+++ php://stdin\n", $fileResult);
 
         $path = str_replace('/', \DIRECTORY_SEPARATOR, basename(realpath($cwd)).'/'.$inputFile);
-        $fileResult = str_replace($path, 'php://stdin', $fileResult);
+        $fileResult = Preg::replace(
+            '#/?'.preg_quote($path, '#').'#',
+            'php://stdin',
+            $fileResult
+        );
 
         static::assertSame(
             $fileResult,