1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Console\Tests\Helper;
13
14use PHPUnit\Framework\TestCase;
15use Symfony\Component\Console\Helper\Helper;
16
17class HelperTest extends TestCase
18{
19    public function formatTimeProvider()
20    {
21        return [
22            [0,      '< 1 sec'],
23            [1,      '1 sec'],
24            [2,      '2 secs'],
25            [59,     '59 secs'],
26            [60,     '1 min'],
27            [61,     '1 min'],
28            [119,    '1 min'],
29            [120,    '2 mins'],
30            [121,    '2 mins'],
31            [3599,   '59 mins'],
32            [3600,   '1 hr'],
33            [7199,   '1 hr'],
34            [7200,   '2 hrs'],
35            [7201,   '2 hrs'],
36            [86399,  '23 hrs'],
37            [86400,  '1 day'],
38            [86401,  '1 day'],
39            [172799, '1 day'],
40            [172800, '2 days'],
41            [172801, '2 days'],
42        ];
43    }
44
45    /**
46     * @dataProvider formatTimeProvider
47     *
48     * @param int    $secs
49     * @param string $expectedFormat
50     */
51    public function testFormatTime($secs, $expectedFormat)
52    {
53        $this->assertEquals($expectedFormat, Helper::formatTime($secs));
54    }
55}
56