diff --git a/src/Toolkit/src/Kit/KitSynchronizer.php b/src/Toolkit/src/Kit/KitSynchronizer.php index 0aaf95840e6..0f13f92168f 100644 --- a/src/Toolkit/src/Kit/KitSynchronizer.php +++ b/src/Toolkit/src/Kit/KitSynchronizer.php @@ -69,8 +69,8 @@ private function synchronizeComponents(Kit $kit): void ; foreach ($finder as $file) { - $relativePathNameToKit = $file->getRelativePathname(); - $relativePathName = str_replace($componentsPath.\DIRECTORY_SEPARATOR, '', $relativePathNameToKit); + $relativePathNameToKit = Path::normalize($file->getRelativePathname()); + $relativePathName = str_replace($componentsPath.'/', '', $relativePathNameToKit); $componentName = $this->extractComponentName($relativePathName); $meta = null; @@ -161,8 +161,8 @@ private function synchronizeStimulusControllers(Kit $kit): void ; foreach ($finder as $file) { - $relativePathNameToKit = $file->getRelativePathname(); - $relativePathName = str_replace($controllersPath.\DIRECTORY_SEPARATOR, '', $relativePathNameToKit); + $relativePathNameToKit = Path::normalize($file->getRelativePathname()); + $relativePathName = str_replace($controllersPath.'/', '', $relativePathNameToKit); $controllerName = $this->extractStimulusControllerName($relativePathName); $controller = new StimulusController( name: $controllerName, diff --git a/src/Toolkit/tests/Command/DebugKitCommandTest.php b/src/Toolkit/tests/Command/DebugKitCommandTest.php index 406d237d05a..7ce441cdad8 100644 --- a/src/Toolkit/tests/Command/DebugKitCommandTest.php +++ b/src/Toolkit/tests/Command/DebugKitCommandTest.php @@ -12,6 +12,7 @@ namespace Symfony\UX\Toolkit\Tests\Command; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\Filesystem\Path; use Zenstruck\Console\Test\InteractsWithConsole; class DebugKitCommandTest extends KernelTestCase @@ -21,7 +22,7 @@ class DebugKitCommandTest extends KernelTestCase public function testShouldBeAbleToDebug(): void { $this->bootKernel(); - $this->consoleCommand(\sprintf('ux:toolkit:debug-kit %s', __DIR__.'/../../kits/shadcn')) + $this->consoleCommand(\sprintf('ux:toolkit:debug-kit %s', Path::join(__DIR__, '/../../kits/shadcn'))) ->execute() ->assertSuccessful() // Kit details @@ -29,28 +30,26 @@ public function testShouldBeAbleToDebug(): void ->assertOutputContains('Homepage https://ux.symfony.com/components') ->assertOutputContains('License MIT') // Components details - ->assertOutputContains(<<<'EOF' -+--------------+----------------------- Component: "Avatar" --------------------------------------+ -| File(s) | templates/components/Avatar.html.twig | -| Dependencies | tales-from-a-dev/twig-tailwind-extra | -| | Avatar:Image | -| | Avatar:Text | -+--------------+----------------------------------------------------------------------------------+ -EOF - ) - ->assertOutputContains(<<<'EOF' -+--------------+----------------------- Component: "Table" ---------------------------------------+ -| File(s) | templates/components/Table.html.twig | -| Dependencies | tales-from-a-dev/twig-tailwind-extra | -| | Table:Body | -| | Table:Caption | -| | Table:Cell | -| | Table:Footer | -| | Table:Head | -| | Table:Header | -| | Table:Row | -+--------------+----------------------------------------------------------------------------------+ -EOF - ); + ->assertOutputContains(implode(\PHP_EOL, [ + '+--------------+----------------------- Component: "Avatar" --------------------------------------+', + '| File(s) | templates/components/Avatar.html.twig |', + '| Dependencies | tales-from-a-dev/twig-tailwind-extra |', + '| | Avatar:Image |', + '| | Avatar:Text |', + '+--------------+----------------------------------------------------------------------------------+', + ])) + ->assertOutputContains(implode(\PHP_EOL, [ + '+--------------+----------------------- Component: "Table" ---------------------------------------+', + '| File(s) | templates/components/Table.html.twig |', + '| Dependencies | tales-from-a-dev/twig-tailwind-extra |', + '| | Table:Body |', + '| | Table:Caption |', + '| | Table:Cell |', + '| | Table:Footer |', + '| | Table:Head |', + '| | Table:Header |', + '| | Table:Row |', + '+--------------+----------------------------------------------------------------------------------+', + ])); } } diff --git a/src/Toolkit/tests/Command/InstallComponentCommandTest.php b/src/Toolkit/tests/Command/InstallComponentCommandTest.php index 79e7e811c50..d2c3274e1ec 100644 --- a/src/Toolkit/tests/Command/InstallComponentCommandTest.php +++ b/src/Toolkit/tests/Command/InstallComponentCommandTest.php @@ -50,7 +50,7 @@ public function testShouldAbleToInstallComponentTableAndItsDependencies(): void $this->assertFileDoesNotExist($expectedFile); } - $testCommand = $this->consoleCommand('ux:toolkit:install-component Table --destination='.$this->tmpDir) + $testCommand = $this->consoleCommand(\sprintf('ux:toolkit:install-component Table --destination="%s"', str_replace('\\', '\\\\', $this->tmpDir))) ->execute() ->assertSuccessful() ->assertOutputContains('Installing component Table from the Shadcn UI kit...')