mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-12 02:02:15 +01:00
Add localization settings
This commit is contained in:
committed by
Gregor Vostrak
parent
3c9160a08a
commit
ae00fdb0e9
97
tests/Unit/Service/CurrencyServiceTest.php
Normal file
97
tests/Unit/Service/CurrencyServiceTest.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Service;
|
||||
|
||||
use App\Service\CurrencyService;
|
||||
use Brick\Money\Currency;
|
||||
use Brick\Money\Money;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\UsesClass;
|
||||
use Tests\TestCaseWithDatabase;
|
||||
|
||||
#[CoversClass(CurrencyService::class)]
|
||||
#[UsesClass(CurrencyService::class)]
|
||||
class CurrencyServiceTest extends TestCaseWithDatabase
|
||||
{
|
||||
private CurrencyService $currencyService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->currencyService = new CurrencyService;
|
||||
}
|
||||
|
||||
public function test_get_currency_symbol_for_currency_eur(): void
|
||||
{
|
||||
// Arrange
|
||||
$money = Money::of(1, Currency::of('EUR'));
|
||||
|
||||
// Act
|
||||
$symbol = $this->currencyService->getCurrencySymbolForMoney($money);
|
||||
|
||||
// Assert
|
||||
$this->assertSame('€', $symbol);
|
||||
}
|
||||
|
||||
public function test_get_currency_symbol_for_currency_usd(): void
|
||||
{
|
||||
// Arrange
|
||||
$money = Money::of(1, Currency::of('USD'));
|
||||
|
||||
// Act
|
||||
$symbol = $this->currencyService->getCurrencySymbolForMoney($money);
|
||||
|
||||
// Assert
|
||||
$this->assertSame('$', $symbol);
|
||||
}
|
||||
|
||||
public function test_get_currency_symbol_for_currency_gbp(): void
|
||||
{
|
||||
// Arrange
|
||||
$money = Money::of(1, Currency::of('GBP'));
|
||||
|
||||
// Act
|
||||
$symbol = $this->currencyService->getCurrencySymbolForMoney($money);
|
||||
|
||||
// Assert
|
||||
$this->assertSame('£', $symbol);
|
||||
}
|
||||
|
||||
public function test_get_currency_symbol_for_currency_cad(): void
|
||||
{
|
||||
// Arrange
|
||||
$money = Money::of(1, Currency::of('CAD'));
|
||||
|
||||
// Act
|
||||
$symbol = $this->currencyService->getCurrencySymbolForMoney($money);
|
||||
|
||||
// Assert
|
||||
$this->assertSame('$', $symbol);
|
||||
}
|
||||
|
||||
public function test_get_currency_symbol_for_currency_cop(): void
|
||||
{
|
||||
// Arrange
|
||||
$money = Money::of(1, Currency::of('COP'));
|
||||
|
||||
// Act
|
||||
$symbol = $this->currencyService->getCurrencySymbolForMoney($money);
|
||||
|
||||
// Assert
|
||||
$this->assertSame('$', $symbol);
|
||||
}
|
||||
|
||||
public function test_get_currency_symbol_for_currency_without_known_symbol(): void
|
||||
{
|
||||
// Arrange
|
||||
$currency = 'XXX';
|
||||
|
||||
// Act
|
||||
$symbol = $this->currencyService->getCurrencySymbol($currency);
|
||||
|
||||
// Assert
|
||||
$this->assertSame('XXX', $symbol);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user