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
|
|
|
|