HelperTest.php 1.4 KB

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