Package system sms
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use App\Models\SmsProfile;
|
||||
use App\Services\Sms\SmsClient;
|
||||
use App\Services\Sms\SmsMessage;
|
||||
use App\Services\Sms\SmsResult;
|
||||
use App\Services\Sms\SmsService;
|
||||
|
||||
it('formats amounts to EU style', function () {
|
||||
$client = new class implements SmsClient
|
||||
{
|
||||
public function send(SmsProfile $profile, SmsMessage $message): SmsResult
|
||||
{
|
||||
throw new RuntimeException('not used');
|
||||
}
|
||||
|
||||
public function getCreditBalance(SmsProfile $profile): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPriceQuotes(SmsProfile $profile): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
$sms = new SmsService($client);
|
||||
|
||||
expect($sms->formatAmountEu(0))->toBe('0,00');
|
||||
expect($sms->formatAmountEu('1'))->toBe('1,00');
|
||||
expect($sms->formatAmountEu('12.3'))->toBe('12,30');
|
||||
expect($sms->formatAmountEu('1234.56'))->toBe('1.234,56');
|
||||
expect($sms->formatAmountEu('9876543.21'))->toBe('9.876.543,21');
|
||||
expect($sms->formatAmountEu('-42.5'))->toBe('-42,50');
|
||||
// Accept EU input too
|
||||
expect($sms->formatAmountEu('1.234,56'))->toBe('1.234,56');
|
||||
});
|
||||
Reference in New Issue
Block a user