52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Jobs\UpsertShopsPickupExceptionsUsingApiForYear;
|
|
use Illuminate\Support\Facades\Bus;
|
|
use Illuminate\Support\Facades\Date;
|
|
|
|
afterEach(function (): void {
|
|
Date::setTestNow();
|
|
});
|
|
|
|
it('dispatches the job for next year when year argument is omitted', function (): void {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $this */
|
|
Date::setTestNow('2026-06-15 10:00:00');
|
|
Bus::fake();
|
|
|
|
// WHEN
|
|
$this->artisan('uwil:upsert-shops-hollydays')
|
|
// THEN
|
|
->assertSuccessful();
|
|
|
|
Bus::assertDispatched(UpsertShopsPickupExceptionsUsingApiForYear::class);
|
|
});
|
|
|
|
it('dispatches the job for the specified numeric year', function (): void {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $this */
|
|
Bus::fake();
|
|
|
|
// WHEN
|
|
$this->artisan('uwil:upsert-shops-hollydays', ['year' => '2027'])
|
|
// THEN
|
|
->assertSuccessful();
|
|
|
|
Bus::assertDispatched(UpsertShopsPickupExceptionsUsingApiForYear::class);
|
|
});
|
|
|
|
it('fails when year argument is not numeric', function (): void {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $this */
|
|
Bus::fake();
|
|
|
|
// WHEN
|
|
$this->artisan('uwil:upsert-shops-hollydays', ['year' => 'abc'])
|
|
// THEN
|
|
->expectsOutput('The year must be a number')
|
|
->assertFailed();
|
|
|
|
Bus::assertNotDispatched(UpsertShopsPickupExceptionsUsingApiForYear::class);
|
|
});
|