Passed
Push — master ( a7ac5a...a9e302 )
by Mark
12:16 queued 15s
created

DurationTest::testTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Style\NumberFormat\Wizard;
4
5
use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Duration;
6
use PHPUnit\Framework\TestCase;
7
8
class DurationTest extends TestCase
9
{
10
    /**
11
     * @dataProvider providerTime
12
     *
13
     * @param null|string|string[] $separators
14
     * @param string[] $formatBlocks
15
     */
16
    public function testTime(string $expectedResult, $separators = null, array $formatBlocks = []): void
17
    {
18
        $wizard = new Duration($separators, ...$formatBlocks);
19
        self::assertSame($expectedResult, (string) $wizard);
20
    }
21
22
    public function providerTime(): array
23
    {
24
        return [
25
            ['[h]:mm:ss', Duration::SEPARATOR_COLON, [Duration::HOURS_DURATION, Duration::MINUTES_LONG, Duration::SECONDS_LONG]],
26
            ['[h]:mm', Duration::SEPARATOR_COLON, [Duration::HOURS_DURATION, Duration::MINUTES_LONG]],
27
            ['[m]:ss', Duration::SEPARATOR_COLON, [Duration::MINUTES_DURATION, Duration::SECONDS_DURATION]],
28
            ['[h]:mm:ss', Duration::SEPARATOR_COLON, [Duration::HOURS_LONG, Duration::MINUTES_LONG, Duration::SECONDS_LONG]],
29
            ['[h]:mm', Duration::SEPARATOR_COLON, [Duration::HOURS_LONG, Duration::MINUTES_LONG]],
30
            ["d\u{a0}h:mm", [Duration::SEPARATOR_SPACE_NONBREAKING, Duration::SEPARATOR_COLON], [Duration::DAYS_DURATION, Duration::HOURS_DURATION, Duration::MINUTES_LONG]],
31
            ['[h]:mm:ss', null, [Duration::HOURS_DURATION, Duration::MINUTES_LONG, Duration::SECONDS_LONG]],
32
            ['[h]:mm:ss'],
33
        ];
34
    }
35
}
36