Minor fixes for updateexchangeratestest

This commit is contained in:
David Bomba 2025-08-15 11:36:51 +10:00
parent 4ed0ccef95
commit 625d78af5d
1 changed files with 14 additions and 10 deletions

View File

@ -11,13 +11,14 @@
namespace Tests\Feature; namespace Tests\Feature;
use App\Jobs\Util\UpdateExchangeRates;
use App\Libraries\Currency\Conversion\CurrencyApi;
use App\Models\Currency;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\MockAccountData;
use Tests\TestCase; use Tests\TestCase;
use App\Models\Currency;
use Tests\MockAccountData;
use App\Utils\Traits\MakesHash;
use App\Jobs\Util\UpdateExchangeRates;
use Illuminate\Support\Facades\Artisan;
use App\Libraries\Currency\Conversion\CurrencyApi;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/** /**
* *
@ -26,9 +27,7 @@ use Tests\TestCase;
class UpdateExchangeRatesTest extends TestCase class UpdateExchangeRatesTest extends TestCase
{ {
use MakesHash; use MakesHash;
use DatabaseTransactions;
use MockAccountData;
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
@ -37,6 +36,10 @@ class UpdateExchangeRatesTest extends TestCase
$this->markTestSkipped("no currency key set"); $this->markTestSkipped("no currency key set");
} }
if (Currency::count() == 0) {
Artisan::call('db:seed', ['--force' => true]);
}
} }
public function testExchangeRate() public function testExchangeRate()
@ -48,10 +51,11 @@ class UpdateExchangeRatesTest extends TestCase
$currency_api = json_decode($response->getBody()); $currency_api = json_decode($response->getBody());
UpdateExchangeRates::dispatchSync(); (new UpdateExchangeRates())->handle();
$gbp_currency = \App\Models\Currency::find(2); $gbp_currency = \App\Models\Currency::find(2);
$this->assertNotNull($gbp_currency);
$this->assertEquals($currency_api->rates->GBP, $gbp_currency->exchange_rate); $this->assertEquals($currency_api->rates->GBP, $gbp_currency->exchange_rate);
} }