| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace Tests\Unit\Helpers;
- use App\Helpers\Price;
- use PHPUnit\Framework\TestCase;
- class PriceHelperTest extends TestCase
- {
- public function test_format_adds_currency_symbol(): void
- {
- $result = Price::format(100.00);
- $this->assertStringContainsString('₽', $result);
- }
- public function test_format_shows_two_decimal_places(): void
- {
- $result = Price::format(100);
- $this->assertStringContainsString('.00', $result);
- }
- public function test_format_handles_decimal_prices(): void
- {
- $result = Price::format(123.45);
- $this->assertStringContainsString('123.45', $result);
- }
- public function test_format_uses_nbsp_as_thousands_separator(): void
- {
- $result = Price::format(1234567.89);
- // is used as thousands separator
- $this->assertStringContainsString(' ', $result);
- $this->assertStringContainsString('1', $result);
- $this->assertStringContainsString('234', $result);
- $this->assertStringContainsString('567', $result);
- $this->assertStringContainsString('.89', $result);
- }
- public function test_format_handles_zero(): void
- {
- $result = Price::format(0);
- $this->assertEquals('0.00₽', $result);
- }
- public function test_format_handles_small_amounts(): void
- {
- $result = Price::format(0.01);
- $this->assertEquals('0.01₽', $result);
- }
- public function test_format_handles_large_amounts(): void
- {
- $result = Price::format(999999999.99);
- $this->assertStringContainsString('₽', $result);
- $this->assertStringContainsString('.99', $result);
- }
- }
|