byos_laravel/tests/Feature/Console/ExampleRecipesSeederCommandTest.php
Benjamin Nussbaum b4b6286172
Some checks are pending
tests / ci (push) Waiting to run
refactor: apply rector
2025-09-24 20:35:48 +02:00

40 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use Database\Seeders\ExampleRecipesSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('example recipes seeder command calls seeder with correct user id', function (): void {
$seeder = Mockery::mock(ExampleRecipesSeeder::class);
$seeder->shouldReceive('run')
->once()
->with('123');
$this->app->instance(ExampleRecipesSeeder::class, $seeder);
$this->artisan('recipes:seed', ['user_id' => '123'])
->assertExitCode(0);
});
test('example recipes seeder command has correct signature', function (): void {
$command = $this->app->make(App\Console\Commands\ExampleRecipesSeederCommand::class);
expect($command->getName())->toBe('recipes:seed');
expect($command->getDescription())->toBe('Seed example recipes');
});
test('example recipes seeder command prompts for missing input', function (): void {
$seeder = Mockery::mock(ExampleRecipesSeeder::class);
$seeder->shouldReceive('run')
->once()
->with('456');
$this->app->instance(ExampleRecipesSeeder::class, $seeder);
$this->artisan('recipes:seed')
->expectsQuestion('What is the user_id?', '456')
->assertExitCode(0);
});