Tests for client currency conversion

This commit is contained in:
David Bomba 2024-01-09 21:29:32 +11:00
parent 293ad19bd8
commit a293f53c08
3 changed files with 19 additions and 0 deletions

View File

@ -17,6 +17,8 @@ return new class extends Migration
return;
}
set_time_limit(0);
Invoice::withTrashed()
->where('is_deleted', false)
->cursor()

View File

@ -32,6 +32,8 @@ class ProductTest extends TestCase
use DatabaseTransactions;
use MockAccountData;
protected $faker;
protected function setUp() :void
{
parent::setUp();

View File

@ -12,6 +12,7 @@
namespace Tests\Unit;
use App\Libraries\Currency\Conversion\CurrencyApi;
use App\Models\Currency;
use Illuminate\Support\Carbon;
use Tests\TestCase;
@ -26,6 +27,20 @@ class CurrencyApiTest extends TestCase
parent::setUp();
}
public function testConversionAudToEur()
{
$converter = new CurrencyApi();
$converted_amount = $converter->convert(100, 12, 3);
$aud_currency = Currency::find(12);
$eur_currency = Currency::find(3);
$converted_synthetic = 100 / ($aud_currency->exchange_rate / $eur_currency->exchange_rate);
$this->assertEquals(round($converted_synthetic, 2), round($converted_amount, 2));
}
public function testCurrencyConversionWorking()
{
$converter = new CurrencyApi();