Skip to content

Commit

Permalink
Merge pull request #473 from range-of-motion/test-jobs-responsible-fo…
Browse files Browse the repository at this point in the history
…r-fetching-conversion-rates

Test jobs responsible for fetching conversion rates
  • Loading branch information
range-of-motion authored Dec 26, 2023
2 parents 4744ca7 + 6143040 commit 0229d72
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 0229d72

Please sign in to comment.