Skip to content

Commit

Permalink
Merge pull request #52 from phh/patch-1
Browse files Browse the repository at this point in the history
[2.x] Add prompts for missing arguments for pest:test
  • Loading branch information
nunomaduro committed Nov 10, 2023
2 parents efb81b1 + ab7a527 commit 5fa7931
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/Commands/PestTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
namespace Pest\Laravel\Commands;

use Illuminate\Console\Command;
use Illuminate\Contracts\Console\PromptsForMissingInput;
use Illuminate\Support\Facades\File;
use Pest\Support\Str;
use Pest\TestSuite;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use function Laravel\Prompts\select;
use function Pest\testDirectory;

/**
* @internal
*/
final class PestTestCommand extends Command
final class PestTestCommand extends Command implements PromptsForMissingInput
{
/**
* The console command name.
Expand Down Expand Up @@ -83,4 +87,29 @@ public function handle(): int

return 0;
}

protected function promptForMissingArgumentsUsing()
{
return [
'name' => 'What should the test be named?',
];
}

/**
* Interact further with the user if they were prompted for missing arguments.
*/
protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output)
{
$type = select('Which type of test would you like?', [
'feature' => 'Feature',
'unit' => 'Unit',
'dusk' => 'Dusk',
]);

match ($type) {
'feature' => null,
'unit' => $input->setOption('unit', true),
'dusk' => $input->setOption('dusk', true),
};
}
}

0 comments on commit 5fa7931

Please sign in to comment.