OrdinalNumeralTest.php 988 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace morphos\test\English;
  3. use morphos\English\OrdinalNumeralGenerator;
  4. use PHPUnit\Framework\TestCase;
  5. class OrdinalNumeralTest extends TestCase
  6. {
  7. /**
  8. * @dataProvider numbersProvider
  9. */
  10. public function testGeneration($number, $ordinal, $figOrdinal)
  11. {
  12. $this->assertEquals($ordinal, OrdinalNumeralGenerator::generate($number));
  13. $this->assertEquals($figOrdinal, OrdinalNumeralGenerator::generate($number, true));
  14. }
  15. public function numbersProvider()
  16. {
  17. return [
  18. [2, 'second', '2nd'],
  19. [30, 'thirtieth', '30th'],
  20. [132, 'one hundred thirty-second', '132nd'],
  21. [2595410, 'two million, five hundred ninety-five thousand, four hundred tenth', '2595410th'],
  22. [
  23. 2021123132,
  24. 'two billion, twenty-one million, one hundred twenty-three thousand, one hundred thirty-second',
  25. '2021123132nd',
  26. ],
  27. ];
  28. }
  29. }