Duration NumberFormat Wizard

This commit is contained in:
MarkBaker
2023-03-23 15:59:15 +01:00
parent 58ac4ca288
commit 0c0fa705db
3 changed files with 189 additions and 1 deletions
@@ -0,0 +1,35 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Style\NumberFormat\Wizard;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Duration;
use PHPUnit\Framework\TestCase;
class DurationTest extends TestCase
{
/**
* @dataProvider providerTime
*
* @param null|string|string[] $separators
* @param string[] $formatBlocks
*/
public function testTime(string $expectedResult, $separators = null, array $formatBlocks = []): void
{
$wizard = new Duration($separators, ...$formatBlocks);
self::assertSame($expectedResult, (string) $wizard);
}
public function providerTime(): array
{
return [
['[h]:mm:ss', Duration::SEPARATOR_COLON, [Duration::HOURS_DURATION, Duration::MINUTES_LONG, Duration::SECONDS_LONG]],
['[h]:mm', Duration::SEPARATOR_COLON, [Duration::HOURS_DURATION, Duration::MINUTES_LONG]],
['[m]:ss', Duration::SEPARATOR_COLON, [Duration::MINUTES_DURATION, Duration::SECONDS_DURATION]],
['[h]:mm:ss', Duration::SEPARATOR_COLON, [Duration::HOURS_LONG, Duration::MINUTES_LONG, Duration::SECONDS_LONG]],
['[h]:mm', Duration::SEPARATOR_COLON, [Duration::HOURS_LONG, Duration::MINUTES_LONG]],
["d\u{a0}h:mm", [Duration::SEPARATOR_SPACE_NONBREAKING, Duration::SEPARATOR_COLON], [Duration::DAYS_DURATION, Duration::HOURS_DURATION, Duration::MINUTES_LONG]],
['[h]:mm:ss', null, [Duration::HOURS_DURATION, Duration::MINUTES_LONG, Duration::SECONDS_LONG]],
['[h]:mm:ss'],
];
}
}