CurrenciesHelperTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace morphos\test;
  3. use morphos\CurrenciesHelper;
  4. use morphos\Currency;
  5. use PHPUnit\Framework\TestCase;
  6. class CurrenciesHelperTest extends TestCase
  7. {
  8. /**
  9. * @dataProvider currenciesProvider
  10. */
  11. public function testCanonizeCase($currency, array $shortcuts)
  12. {
  13. $this->assertEquals($currency, CurrenciesHelper::canonizeCurrency($currency));
  14. foreach ($shortcuts as $shortcut) {
  15. $this->assertEquals($currency, CurrenciesHelper::canonizeCurrency($shortcut));
  16. }
  17. }
  18. public function currenciesProvider()
  19. {
  20. return [
  21. [Currency::DOLLAR, ['$', 'usd', 'dollar']],
  22. [Currency::EURO, ['€', 'euro']],
  23. [Currency::YEN, ['¥']],
  24. [Currency::POUND, ['£']],
  25. [Currency::FRANC, ['Fr']],
  26. [Currency::YUAN, ['元']],
  27. [Currency::KRONA, ['Kr']],
  28. [Currency::PESO, []],
  29. [Currency::WON, ['₩']],
  30. [Currency::LIRA, ['₺']],
  31. [Currency::RUBLE, ['₽', 'ruble']],
  32. [Currency::RUPEE, ['₹']],
  33. [Currency::REAL, ['R$']],
  34. [Currency::RAND, ['R']],
  35. [Currency::HRYVNIA, ['₴']],
  36. ];
  37. }
  38. public function testCanonizeCurrency()
  39. {
  40. $this->expectException(\InvalidArgumentException::class);
  41. CurrenciesHelper::canonizeCurrency('Invalid-Case');
  42. }
  43. }