test: improve coverage

This commit is contained in:
Benjamin Nussbaum 2025-09-23 23:56:11 +02:00
parent 4f251bf37e
commit e9fc6b2335
7 changed files with 630 additions and 0 deletions

View file

@ -0,0 +1,40 @@
<?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 () {
$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 () {
$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 () {
$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);
});

View file

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use App\Jobs\FirmwarePollJob;
use App\Models\Firmware;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('firmware check command has correct signature', function () {
$command = $this->app->make(\App\Console\Commands\FirmwareCheckCommand::class);
expect($command->getName())->toBe('trmnl:firmware:check');
expect($command->getDescription())->toBe('Checks for the latest firmware and downloads it if flag --download is passed.');
});
test('firmware check command runs without errors', function () {
$this->artisan('trmnl:firmware:check')
->assertExitCode(0);
});
test('firmware check command runs with download flag', function () {
$this->artisan('trmnl:firmware:check', ['--download' => true])
->assertExitCode(0);
});
test('firmware check command can run successfully', function () {
$this->artisan('trmnl:firmware:check')
->assertExitCode(0);
});