AlternativeNumbersTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of the Carbon package.
  5. *
  6. * (c) Brian Nesbitt <brian@nesbot.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Tests\CarbonInterval;
  12. use Carbon\CarbonInterval;
  13. use Tests\AbstractTestCase;
  14. class AlternativeNumbersTest extends AbstractTestCase
  15. {
  16. public function testAlternativesNumbers()
  17. {
  18. $this->assertSame(
  19. '۵۲ ساعت',
  20. CarbonInterval::hours(52)->locale('fa')->forHumans(['altNumbers' => true])
  21. );
  22. $this->assertSame(
  23. '۰۱ ساعت',
  24. CarbonInterval::hour()->locale('fa')->forHumans(['altNumbers' => 'fa'])
  25. );
  26. $this->assertSame(
  27. '1時間',
  28. CarbonInterval::hour()->locale('ja')->forHumans(['altNumbers' => 'fa'])
  29. );
  30. $this->assertSame(
  31. '۰۱ ساعت',
  32. CarbonInterval::hour()->locale('fa')->forHumans(['altNumbers' => ['fa', 'ja']])
  33. );
  34. $this->assertSame(
  35. '52 ساعت',
  36. CarbonInterval::hours(52)->locale('fa')->forHumans(['altNumbers' => 'ja'])
  37. );
  38. $this->assertSame(
  39. '52 ساعت',
  40. CarbonInterval::hours(52)->locale('fa')->forHumans(['altNumbers' => ['lzh', 'ja']])
  41. );
  42. $this->assertSame(
  43. '五十二時間',
  44. CarbonInterval::hours(52)->locale('ja')->forHumans(['altNumbers' => ['lzh', 'ja']])
  45. );
  46. $this->assertSame(
  47. '-6',
  48. CarbonInterval::hours(-6)->locale('fa')->translateNumber(-6)
  49. );
  50. }
  51. }