From 55992c8edbd49e506354fe6667ca1418553a87a8 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 15 Nov 2023 13:59:47 +0200 Subject: [PATCH 1/4] Fix normalizePath for Windows --- installer/Internal/Events/CopyEvent.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/installer/Internal/Events/CopyEvent.php b/installer/Internal/Events/CopyEvent.php index cfe8f04..95a34eb 100644 --- a/installer/Internal/Events/CopyEvent.php +++ b/installer/Internal/Events/CopyEvent.php @@ -60,10 +60,12 @@ public function normalizePath(string $root, string $path): string $source = \ltrim($path, '/'); if ($sourceRoot === '') { - return '/' . $source; + return \file_exists($source) ? $source : '/' . $source; } - return '/' . $sourceRoot . '/' . $source; + return \file_exists($sourceRoot . '/' . $source) + ? $sourceRoot . '/' . $source + : '/' . $sourceRoot . '/' . $source; } public function detectType(string $path): string From fac69198697073322fe1377384e8873bdecb785d Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 15 Nov 2023 14:16:35 +0200 Subject: [PATCH 2/4] Fix test for actual version of nette/php-generator --- .../Unit/Internal/Generator/Bootloader/ClassBindingTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/installer/Tests/Unit/Internal/Generator/Bootloader/ClassBindingTest.php b/installer/Tests/Unit/Internal/Generator/Bootloader/ClassBindingTest.php index 29fa801..4af5fb4 100644 --- a/installer/Tests/Unit/Internal/Generator/Bootloader/ClassBindingTest.php +++ b/installer/Tests/Unit/Internal/Generator/Bootloader/ClassBindingTest.php @@ -5,6 +5,7 @@ namespace Tests\Unit\Internal\Generator\Bootloader; use Installer\Internal\Generator\Bootloader\ClassBinding; +use Nette\PhpGenerator\Printer; use Spiral\Reactor\Partial\PhpNamespace; use Tests\TestCase; @@ -22,6 +23,9 @@ public function testRender(): void $binding->render($namespace = new PhpNamespace('App')) ); + $printer = new Printer(); + $printer->omitEmptyNamespaces = false; + $this->assertSame( <<printNamespace($namespace->getElement()) ); } } From 25e9317d4b947cdd9bbfcbb030e64c07c74910b1 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 15 Nov 2023 14:21:23 +0200 Subject: [PATCH 3/4] Up min version of nette/php-generator --- installer/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/composer.json b/installer/composer.json index 949fcf1..d1fec5c 100644 --- a/installer/composer.json +++ b/installer/composer.json @@ -3,7 +3,7 @@ "license": "MIT", "description": "Spiral Application installer", "require-dev": { - "nette/php-generator": "^4.0", + "nette/php-generator": "^4.1.2", "spiral/framework": "^3.8", "spiral/nyholm-bridge": "^1.0", "composer/composer": "^2.4", From 76c3e419cc1d689e69e34e33f42cc03402c506a9 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 15 Nov 2023 14:40:17 +0200 Subject: [PATCH 4/4] Fix tests in Windows --- installer/Tests/InstallationResult.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/Tests/InstallationResult.php b/installer/Tests/InstallationResult.php index 51740ca..4955ccf 100644 --- a/installer/Tests/InstallationResult.php +++ b/installer/Tests/InstallationResult.php @@ -337,7 +337,7 @@ public function assertCopied(string $path, string $destination): self { foreach ($this->events as $event) { if ($event instanceof CopyEvent) { - if (\str_ends_with($event->getFullSource(), $path)) { + if (\str_ends_with(\str_replace('\\', '/', $event->getFullSource()), \str_replace('\\', '/', $path))) { if (\str_ends_with($event->getFullDestination(), $destination)) { Assert::assertTrue(true);