Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/WalletTest.php
<?php | <?php | ||||
namespace Tests\Unit; | namespace Tests\Unit; | ||||
use App\Wallet; | use App\Wallet; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class WalletTest extends TestCase | class WalletTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* Test Wallet::money() | * Test Wallet::money() | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function testMoney() | public function testMoney() | ||||
{ | { | ||||
$wallet = new Wallet([ | // This test is here to remind us that the method will give | ||||
'currency' => 'CHF', | // different results for different locales | ||||
]); | |||||
$wallet = new Wallet(['currency' => 'CHF']); | |||||
$money = $wallet->money(-123); | $money = $wallet->money(-123); | ||||
$this->assertSame('-1,23 CHF', $money); | $this->assertSame('-1,23 CHF', $money); | ||||
// This test is here to remind us that the method will give | $wallet = new Wallet(['currency' => 'EUR']); | ||||
// different results for different locales, but also depending | $money = $wallet->money(-123); | ||||
// if NumberFormatter (intl extension) is installed or not. | |||||
// NumberFormatter also returns some surprising output for | $this->assertSame('-1,23 €', $money); | ||||
// some locales and e.g. negative numbers. | |||||
// We'd have to improve on that as soon as we'd want to use | |||||
// other locale than the default de_DE. | |||||
} | } | ||||
} | } |