HelperTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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\Console\Tests\Helper;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Console\Helper\Helper;
  13. class HelperTest extends TestCase
  14. {
  15. public function formatTimeProvider()
  16. {
  17. return array(
  18. array(0, '< 1 sec'),
  19. array(1, '1 sec'),
  20. array(2, '2 secs'),
  21. array(59, '59 secs'),
  22. array(60, '1 min'),
  23. array(61, '1 min'),
  24. array(119, '1 min'),
  25. array(120, '2 mins'),
  26. array(121, '2 mins'),
  27. array(3599, '59 mins'),
  28. array(3600, '1 hr'),
  29. array(7199, '1 hr'),
  30. array(7200, '2 hrs'),
  31. array(7201, '2 hrs'),
  32. array(86399, '23 hrs'),
  33. array(86400, '1 day'),
  34. array(86401, '1 day'),
  35. array(172799, '1 day'),
  36. array(172800, '2 days'),
  37. array(172801, '2 days'),
  38. );
  39. }
  40. /**
  41. * @dataProvider formatTimeProvider
  42. *
  43. * @param int $secs
  44. * @param string $expectedFormat
  45. */
  46. public function testFormatTime($secs, $expectedFormat)
  47. {
  48. $this->assertEquals($expectedFormat, Helper::formatTime($secs));
  49. }
  50. }