diff --git a/test/ComposerRequireCheckerTest/FileLocator/LocateAllFilesByExtensionTest.php b/test/ComposerRequireCheckerTest/FileLocator/LocateAllFilesByExtensionTest.php index b07e6396..0e5a6ba2 100644 --- a/test/ComposerRequireCheckerTest/FileLocator/LocateAllFilesByExtensionTest.php +++ b/test/ComposerRequireCheckerTest/FileLocator/LocateAllFilesByExtensionTest.php @@ -52,10 +52,11 @@ public function testLocateFromASingleDirectory(): void } $foundFiles = $this->locate([$dir], '.php', null); + $foundFiles = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $foundFiles); $this->assertCount(count($files), $foundFiles); foreach ($files as $file) { - $this->assertContains($file, str_replace('\\', '/', $foundFiles)); + $this->assertContains($file, $foundFiles); } } @@ -157,7 +158,7 @@ private function locate(array $directories, string $fileExtension, array|null $b { $files = []; foreach (($this->locator)(new ArrayObject($directories), $fileExtension, $blacklist) as $file) { - $files[] = str_replace('\\', '/', $file); + $files[] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $file); } return $files; diff --git a/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageDirectDependenciesSourceFilesTest.php b/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageDirectDependenciesSourceFilesTest.php index 55e0bb96..f304766c 100644 --- a/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageDirectDependenciesSourceFilesTest.php +++ b/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageDirectDependenciesSourceFilesTest.php @@ -63,7 +63,7 @@ public function testSingleDependency(): void $this->assertCount(1, $files); $expectedFile = $this->path('vendor/foo/bar/src/MyClass.php'); - $actualFile = str_replace('\\', '/', reset($files)); + $actualFile = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, reset($files)); $this->assertSame($expectedFile, $actualFile); } @@ -89,7 +89,7 @@ public function testVendorConfigSettingIsBeingUsed(): void $this->assertCount(1, $files); $expectedFile = $this->path('alternate-vendor/foo/bar/src/MyClass.php'); - $actualFile = str_replace('\\', '/', reset($files)); + $actualFile = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, reset($files)); $this->assertSame($expectedFile, $actualFile); } @@ -104,7 +104,7 @@ public function testInstalledJsonUsedAsFallback(): void $this->assertCount(1, $files); $expectedFile = $this->path('vendor/foo/bar/src/MyClass.php'); - $actualFile = str_replace('\\', '/', reset($files)); + $actualFile = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, reset($files)); $this->assertSame($expectedFile, $actualFile); // Ensure we didn't leave our temporary composer.json lying around @@ -125,7 +125,7 @@ public function testOldInstalledJsonUsedAsFallback(): void $this->assertCount(1, $files); $expectedFile = $this->path('vendor/foo/bar/src/MyClass.php'); - $actualFile = str_replace('\\', '/', reset($files)); + $actualFile = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, reset($files)); $this->assertSame($expectedFile, $actualFile); // Ensure we didn't leave our temporary composer.json lying around diff --git a/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageSourceFilesTest.php b/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageSourceFilesTest.php index 0b76e4e4..fab11ba4 100644 --- a/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageSourceFilesTest.php +++ b/test/ComposerRequireCheckerTest/FileLocator/LocateComposerPackageSourceFilesTest.php @@ -215,7 +215,7 @@ private function files(string $composerJson): array $files = []; $filesGenerator = ($this->locator)($composerData, dirname($composerJson)); foreach ($filesGenerator as $file) { - $files[] = str_replace('\\', '/', $file); + $files[] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $file); } return $files; diff --git a/test/ComposerRequireCheckerTest/FileLocator/LocateFilesByGlobPatternTest.php b/test/ComposerRequireCheckerTest/FileLocator/LocateFilesByGlobPatternTest.php index 94377f34..2fe06e3d 100644 --- a/test/ComposerRequireCheckerTest/FileLocator/LocateFilesByGlobPatternTest.php +++ b/test/ComposerRequireCheckerTest/FileLocator/LocateFilesByGlobPatternTest.php @@ -8,6 +8,8 @@ use PHPUnit\Framework\TestCase; use Spatie\TemporaryDirectory\TemporaryDirectory; +use function array_map; +use function realpath; use function str_replace; use function touch; @@ -43,10 +45,13 @@ public function testGlobPattern(): void touch($this->path('bin/console123.php')); touch($this->path('bin/not-console')); - $files = $this->files(['bin/console*.php'], $this->root->path() . '/'); + $files = $this->files(['bin' . DIRECTORY_SEPARATOR . 'console*.php'], $this->root->path() . DIRECTORY_SEPARATOR); + $files = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $files); + $files = array_map('realpath', $files); + self::assertCount(2, $files); - self::assertContains($this->path('bin/console.php'), $files); - self::assertContains($this->path('bin/console123.php'), $files); + self::assertContains(realpath($this->path('bin/console.php')), $files); + self::assertContains(realpath($this->path('bin/console123.php')), $files); } /** @@ -59,7 +64,7 @@ private function files(array $globPatterns, string $dir): array $files = []; $filesGenerator = ($this->locator)($globPatterns, $dir); foreach ($filesGenerator as $file) { - $files[] = $file; + $files[] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $file); } return $files;