From 44a3fa12edbd102f8de0dea0aa3306a328766625 Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Wed, 13 Sep 2023 17:19:41 +0100 Subject: [PATCH 1/4] feat: add support for Pest in `vapor test` --- src/Commands/TestCommand.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Commands/TestCommand.php b/src/Commands/TestCommand.php index e47ec7de..5fc138cb 100644 --- a/src/Commands/TestCommand.php +++ b/src/Commands/TestCommand.php @@ -30,7 +30,7 @@ protected function configure() $this ->setName('test') ->addOption('php', null, InputOption::VALUE_OPTIONAL, 'The PHP version that should be used to execute the tests') - ->setDescription('Run PHPUnit inside a simulated Vapor environment'); + ->setDescription('Run PHPUnit or Pest inside a simulated Vapor environment'); } /** @@ -42,10 +42,20 @@ protected function configure() */ public function handle() { - array_splice($_SERVER['argv'], 2, 0, 'vendor/bin/phpunit'); + array_splice($_SERVER['argv'], 2, 0, $this->getTestRunnerBinary()); $this->getApplication()->find('local')->run(new ArrayInput([ '--php' => $this->option('php'), ]), $this->output); } + + /** + * Returns the test runner binary. + * + * @return string + */ + protected function getTestRunnerBinary() + { + return is_executable('vendor/bin/pest') ? 'vendor/bin/pest' : 'vendor/bin/phpunit'; + } } From 506318c34e3ba793e2a35ca90e430059f11d9a11 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Thu, 14 Sep 2023 15:49:33 +0100 Subject: [PATCH 2/4] set working directory --- src/Commands/LocalCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Commands/LocalCommand.php b/src/Commands/LocalCommand.php index 35c6287e..9fd8782c 100644 --- a/src/Commands/LocalCommand.php +++ b/src/Commands/LocalCommand.php @@ -79,6 +79,7 @@ public function handle() '-e DB_USERNAME=vapor', '-e DB_PASSWORD=secret', '-e REDIS_HOST=redis', + '-w /app', '-v', Path::current().':/app', 'app', From 67ddb58bd22ea29fb23e4a77beb13c35eb655938 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Thu, 14 Sep 2023 16:50:56 +0100 Subject: [PATCH 3/4] handle --pest option --- src/Commands/LocalCommand.php | 2 +- src/Commands/TestCommand.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Commands/LocalCommand.php b/src/Commands/LocalCommand.php index 9fd8782c..e9a57553 100644 --- a/src/Commands/LocalCommand.php +++ b/src/Commands/LocalCommand.php @@ -57,7 +57,7 @@ protected function configure() */ public function handle() { - $options = array_slice($_SERVER['argv'], $this->option('php') ? 3 : 2); + $options = array_slice($_SERVER['argv'], $this->option('php') && array_search('--php='.$this->option('php'), $_SERVER['argv']) !== false ? 3 : 2); $status = 0; diff --git a/src/Commands/TestCommand.php b/src/Commands/TestCommand.php index 5fc138cb..20a55a8b 100644 --- a/src/Commands/TestCommand.php +++ b/src/Commands/TestCommand.php @@ -30,6 +30,7 @@ protected function configure() $this ->setName('test') ->addOption('php', null, InputOption::VALUE_OPTIONAL, 'The PHP version that should be used to execute the tests') + ->addOption('pest', null, InputOption::VALUE_NONE, 'Run Pest tests') ->setDescription('Run PHPUnit or Pest inside a simulated Vapor environment'); } @@ -42,7 +43,7 @@ protected function configure() */ public function handle() { - array_splice($_SERVER['argv'], 2, 0, $this->getTestRunnerBinary()); + array_splice($_SERVER['argv'], 2, count($_SERVER['argv']), $this->getTestRunnerBinary()); $this->getApplication()->find('local')->run(new ArrayInput([ '--php' => $this->option('php'), @@ -56,6 +57,6 @@ public function handle() */ protected function getTestRunnerBinary() { - return is_executable('vendor/bin/pest') ? 'vendor/bin/pest' : 'vendor/bin/phpunit'; + return $this->option('pest') ? 'vendor/bin/pest' : 'vendor/bin/phpunit'; } } From 5cb48e329fdf5fc26f75cea7fa769b30f03e7a57 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 15 Sep 2023 08:20:13 -0500 Subject: [PATCH 4/4] Update TestCommand.php --- src/Commands/TestCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/TestCommand.php b/src/Commands/TestCommand.php index 20a55a8b..77a77dcb 100644 --- a/src/Commands/TestCommand.php +++ b/src/Commands/TestCommand.php @@ -51,7 +51,7 @@ public function handle() } /** - * Returns the test runner binary. + * Determine the test runner binary. * * @return string */