Passed
Push — master ( 66b95b...1192d3 )
by Mark
21:21 queued 10:15
created

TimeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A providerTime() 0 7 1
A testTime() 0 4 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Style\NumberFormat\Wizard;
4
5
use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Time;
6
use PHPUnit\Framework\TestCase;
7
8
class TimeTest 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, array $formatBlocks): void
17
    {
18
        $wizard = new Time($separators, ...$formatBlocks);
19
        self::assertSame($expectedResult, (string) $wizard);
20
    }
21
22
    public function providerTime(): array
23
    {
24
        return [
25
            ['hh:mm:ss', Time::SEPARATOR_COLON, [Time::HOURS_LONG, Time::MINUTES_LONG, Time::SECONDS_LONG]],
26
            ['hh:mm', Time::SEPARATOR_COLON, [Time::HOURS_LONG, Time::MINUTES_LONG]],
27
            ['hh:mm AM/PM', [Time::SEPARATOR_COLON, Time::SEPARATOR_SPACE], [Time::HOURS_LONG, Time::MINUTES_LONG, Time::MORNING_AFTERNOON]],
28
            ['h "hours and" m "minutes past midnight"', Time::SEPARATOR_SPACE, [Time::HOURS_SHORT, 'hours and', Time::MINUTES_SHORT, 'minutes past midnight']],
29
        ];
30
    }
31
}
32