IntervalTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Translation\Interval;
  13. /**
  14. * @group legacy
  15. */
  16. class IntervalTest extends TestCase
  17. {
  18. /**
  19. * @dataProvider getTests
  20. */
  21. public function testTest($expected, $number, $interval)
  22. {
  23. $this->assertEquals($expected, Interval::test($number, $interval));
  24. }
  25. /**
  26. * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
  27. */
  28. public function testTestException()
  29. {
  30. Interval::test(1, 'foobar');
  31. }
  32. public function getTests()
  33. {
  34. return [
  35. [true, 3, '{1,2, 3 ,4}'],
  36. [false, 10, '{1,2, 3 ,4}'],
  37. [false, 3, '[1,2]'],
  38. [true, 1, '[1,2]'],
  39. [true, 2, '[1,2]'],
  40. [false, 1, ']1,2['],
  41. [false, 2, ']1,2['],
  42. [true, log(0), '[-Inf,2['],
  43. [true, -log(0), '[-2,+Inf]'],
  44. ];
  45. }
  46. }