Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Jan 16, 2025
1 parent 4c95366 commit 7095afe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/Feature/EnumMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@
]);

it('generates enums with prompts', function() {
$command = $this->artisan('enum:make')
// Currently textarea() of Laravel Prompts seems to have some testing issues.
// Apparently the method expectsQuestion() does not test textarea rightly.
// In alternative, we fallback the prompt with the expected user input.
TextareaPrompt::fallbackUsing(fn() => 'CaseOne' . PHP_EOL . 'CaseTwo');

$command = $this->artisan('enum:make', ['cases' => ['CaseOne', 'CaseTwo']])
->expectsQuestion('The namespace of the enum', 'App\Enums\Generated1')
->expectsQuestion('How cases should be backed', 'bitwise')
->expectsQuestion('The cases (one per line)', 'CaseOne' . PHP_EOL . 'CaseTwo');
->expectsQuestion('How cases should be backed', 'bitwise');

expect($command)->toGenerate('App\Enums\Generated1');
});

0 comments on commit 7095afe

Please sign in to comment.