Skip to content

Commit

Permalink
Test jobs responsible for fetching conversion rates
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Dec 26, 2023
1 parent 4744ca7 commit 6143040
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Unit/Jobs/FetchConversionRateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Tests\Unit\Jobs;

use App\Jobs\FetchConversionRate;
use App\Models\ConversionRate;
use Tests\TestCase;

class FetchConversionRateTest extends TestCase
{
public function testWhetherConversionRatesGetFetched(): void
{
$this->assertDatabaseEmpty(ConversionRate::class);

app()->call([new FetchConversionRate(1), 'handle']);

$this->assertDatabaseHas(
ConversionRate::class,
[
'base_currency_id' => 1,
'target_currency_id' => 2,
],
);

$this->assertDatabaseHas(
ConversionRate::class,
[
'base_currency_id' => 1,
'target_currency_id' => 3,
],
);

// etc.
}
}
22 changes: 22 additions & 0 deletions tests/Unit/Jobs/FetchConversionRatesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Tests\Unit\Jobs;

use App\Jobs\FetchConversionRate;
use App\Jobs\FetchConversionRates;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;

class FetchConversionRatesTest extends TestCase
{
public function testWhetherIndividualJobsGetDispatched(): void
{
Queue::fake();

Queue::assertNothingPushed();

app()->call([new FetchConversionRates(), 'handle']);

Queue::assertPushed(FetchConversionRate::class);
}
}

0 comments on commit 6143040

Please sign in to comment.