diff --git a/src/Laravel/Commands/PestInstallCommand.php b/src/Laravel/Commands/PestInstallCommand.php index 17a71095..696eba6b 100644 --- a/src/Laravel/Commands/PestInstallCommand.php +++ b/src/Laravel/Commands/PestInstallCommand.php @@ -7,6 +7,7 @@ namespace Pest\Laravel\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Pest\Exceptions\InvalidConsoleArgument; +use Pest\Support\Str; /** * @internal @@ -36,6 +37,8 @@ final class PestInstallCommand extends Command $pest = base_path('tests/Pest.php'); /* @phpstan-ignore-next-line */ $helpers = base_path('tests/Helpers.php'); + /* @phpstan-ignore-next-line */ + $stubs = $this->isLumen() ? 'stubs/Lumen' : 'stubs/Laravel'; foreach ([$pest, $helpers] as $file) { if (File::exists($file)) { @@ -45,17 +48,25 @@ final class PestInstallCommand extends Command File::copy(implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__, 3), - 'stubs', + $stubs, 'Pest.php', ]), $pest); File::copy(implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__, 3), - 'stubs', + $stubs, 'Helpers.php', ]), $helpers); $this->output->success('`tests/Pest.php` created successfully.'); $this->output->success('`tests/Helpers.php` created successfully.'); } + + /** + * Determine if this is a Lumen application. + */ + protected function isLumen(): bool + { + return Str::startsWith(app()->version(), 'Lumen'); + } } diff --git a/stubs/Helpers.php b/stubs/Laravel/Helpers.php similarity index 100% rename from stubs/Helpers.php rename to stubs/Laravel/Helpers.php diff --git a/stubs/Pest.php b/stubs/Laravel/Pest.php similarity index 100% rename from stubs/Pest.php rename to stubs/Laravel/Pest.php diff --git a/stubs/phpunit.xml b/stubs/Laravel/phpunit.xml similarity index 100% rename from stubs/phpunit.xml rename to stubs/Laravel/phpunit.xml diff --git a/stubs/Lumen/Helpers.php b/stubs/Lumen/Helpers.php new file mode 100644 index 00000000..03f67ea2 --- /dev/null +++ b/stubs/Lumen/Helpers.php @@ -0,0 +1,11 @@ +actingAs($user, $driver); +} diff --git a/stubs/Lumen/Pest.php b/stubs/Lumen/Pest.php new file mode 100644 index 00000000..43d41c89 --- /dev/null +++ b/stubs/Lumen/Pest.php @@ -0,0 +1,3 @@ + + + + + ./tests + + + + + ./app + + +