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 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); 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()) ); } } 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",