diff --git a/src/Adapters/Laravel/Commands/TestCommand.php b/src/Adapters/Laravel/Commands/TestCommand.php index ee3637f4..e5a29111 100644 --- a/src/Adapters/Laravel/Commands/TestCommand.php +++ b/src/Adapters/Laravel/Commands/TestCommand.php @@ -29,7 +29,8 @@ class TestCommand extends Command */ protected $signature = 'test {--without-tty : Disable output to TTY} - {--parallel : Whether the tests should be run in parallel} + {--parallel : Indicates if the tests should run in parallel} + {--refresh-databases : Indicates if the test databases should be re-created} '; /** @@ -96,7 +97,10 @@ public function handle() ), null, // Envs ... - $parallel ? ['LARAVEL_PARALLEL_TESTING' => 1] : [], + $parallel ? [ + 'LARAVEL_PARALLEL_TESTING' => 1, + 'LARAVEL_PARALLEL_TESTING_REFRESH_DATABASES' => $this->option('refresh-databases'), + ] : [], ))->setTimeout(null); try { @@ -175,7 +179,8 @@ protected function paratestArguments($options) { $options = array_values(array_filter($options, function ($option) { return !Str::startsWith($option, '--env=') - && !Str::startsWith($option, '--parallel'); + && !Str::startsWith($option, '--parallel') + && !Str::startsWith($option, '--refresh-databases'); })); if (!file_exists($file = base_path('phpunit.xml'))) { diff --git a/tests/LaravelApp/app/Console/Commands/TestCommand.php b/tests/LaravelApp/app/Console/Commands/TestCommand.php index 08df3cf9..9cbb7cd7 100644 --- a/tests/LaravelApp/app/Console/Commands/TestCommand.php +++ b/tests/LaravelApp/app/Console/Commands/TestCommand.php @@ -15,6 +15,18 @@ class TestCommand extends BaseTestCommand */ protected function binary() { + switch (true) { + case $this->option('parallel'): + $command = 'vendor/brianium/paratest/bin/paratest'; + break; + case class_exists(\Pest\Laravel\PestServiceProvider::class): + $command = 'vendor/pestphp/pest/bin/pest'; + break; + default: + $command = 'vendor/phpunit/phpunit/phpunit'; + break; + } + if ('phpdbg' === PHP_SAPI) { return [PHP_BINARY, '-qrr', __DIR__ . '/../../../../../vendor/bin/phpunit']; } diff --git a/tests/Unit/Adapters/ArtisanTestCommandTest.php b/tests/Unit/Adapters/ArtisanTestCommandTest.php index e5df8d20..3124998a 100644 --- a/tests/Unit/Adapters/ArtisanTestCommandTest.php +++ b/tests/Unit/Adapters/ArtisanTestCommandTest.php @@ -22,7 +22,6 @@ public function testEnv(): void ]); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environment']); - $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environment']); } /** @test */ @@ -43,7 +42,6 @@ public function testEnvTesting(): void ]); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environmentTesting']); - $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environmentTesting']); } /**