From 489c7905d4dce6b762a51d7f6305a8b6368fe535 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Mon, 30 Oct 2023 13:38:47 -0400 Subject: [PATCH] fixing windows tests --- .../Component/AssetMapper/ImportMap/ImportMapConfigReader.php | 3 ++- .../AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapConfigReader.php b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapConfigReader.php index f1049b8e13b89..cbcd8024e0d34 100644 --- a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapConfigReader.php +++ b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapConfigReader.php @@ -174,7 +174,8 @@ public function convertFilesystemPathToPath(string $filesystemPath): ?string return null; } - return './'.substr($filesystemPath, \strlen($rootImportMapDir) + 1); + // remove the root directory, prepend "./" & normalize slashes + return './'.str_replace('\\', '/', substr($filesystemPath, \strlen($rootImportMapDir) + 1)); } private function getRootDirectory(): string diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php index c1b3017f02ccc..fbfb8b4654664 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php @@ -115,6 +115,8 @@ public function testGetEntriesAndWriteEntries() public function testConvertPathToFilesystemPath(string $path, string $expectedPath) { $configReader = new ImportMapConfigReader(realpath(__DIR__.'/../Fixtures/importmap.php'), $this->createMock(RemotePackageStorage::class)); + // normalize path separators for comparison + $expectedPath = str_replace('\\', '/', $expectedPath); $this->assertSame($expectedPath, $configReader->convertPathToFilesystemPath($path)); }