Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Pest in vapor test #233

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Commands/LocalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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',
Expand Down
15 changes: 13 additions & 2 deletions src/Commands/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ 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');
->addOption('pest', null, InputOption::VALUE_NONE, 'Run Pest tests')
->setDescription('Run PHPUnit or Pest inside a simulated Vapor environment');
}

/**
Expand All @@ -42,10 +43,20 @@ protected function configure()
*/
public function handle()
{
array_splice($_SERVER['argv'], 2, 0, 'vendor/bin/phpunit');
array_splice($_SERVER['argv'], 2, count($_SERVER['argv']), $this->getTestRunnerBinary());

$this->getApplication()->find('local')->run(new ArrayInput([
'--php' => $this->option('php'),
]), $this->output);
}

/**
* Determine the test runner binary.
*
* @return string
*/
protected function getTestRunnerBinary()
{
return $this->option('pest') ? 'vendor/bin/pest' : 'vendor/bin/phpunit';
}
}
Loading