HelperTest.php 1.4 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 [
  18. [0, '< 1 sec'],
  19. [1, '1 sec'],
  20. [2, '2 secs'],
  21. [59, '59 secs'],
  22. [60, '1 min'],
  23. [61, '1 min'],
  24. [119, '1 min'],
  25. [120, '2 mins'],
  26. [121, '2 mins'],
  27. [3599, '59 mins'],
  28. [3600, '1 hr'],
  29. [7199, '1 hr'],
  30. [7200, '2 hrs'],
  31. [7201, '2 hrs'],
  32. [86399, '23 hrs'],
  33. [86400, '1 day'],
  34. [86401, '1 day'],
  35. [172799, '1 day'],
  36. [172800, '2 days'],
  37. [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. }