mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-25 19:38:19 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
40 lines
2.0 KiB
PHP
40 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Style\NumberFormat\Wizard;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Date;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class DateTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider providerDate
|
|
*
|
|
* @param null|string|string[] $separators
|
|
* @param string[] $formatBlocks
|
|
*/
|
|
public function testDate(string $expectedResult, string|array|null $separators = null, array $formatBlocks = []): void
|
|
{
|
|
$wizard = new Date($separators, ...$formatBlocks);
|
|
self::assertSame($expectedResult, (string) $wizard);
|
|
}
|
|
|
|
public static function providerDate(): array
|
|
{
|
|
return [
|
|
['yyyy-mm-dd', Date::SEPARATOR_DASH, [Date::YEAR_FULL, Date::MONTH_NUMBER_LONG, Date::DAY_NUMBER_LONG]],
|
|
['mm/dd/yyyy', Date::SEPARATOR_SLASH, [Date::MONTH_NUMBER_LONG, Date::DAY_NUMBER_LONG, Date::YEAR_FULL]],
|
|
['dd.mm.yyyy', Date::SEPARATOR_DOT, [Date::DAY_NUMBER_LONG, Date::MONTH_NUMBER_LONG, Date::YEAR_FULL]],
|
|
['dd-mmm-yyyy', Date::SEPARATOR_DASH, [Date::DAY_NUMBER_LONG, Date::MONTH_NAME_SHORT, Date::YEAR_FULL]],
|
|
['dd-mmm yyyy', [Date::SEPARATOR_DASH, Date::SEPARATOR_SPACE], [Date::DAY_NUMBER_LONG, Date::MONTH_NAME_SHORT, Date::YEAR_FULL]],
|
|
['dddd dd.mm.yyyy', [Date::SEPARATOR_SPACE, Date::SEPARATOR_DOT], [Date::WEEKDAY_NAME_LONG, Date::DAY_NUMBER_LONG, Date::MONTH_NUMBER_LONG, Date::YEAR_FULL]],
|
|
['dd-mm "in the year" yyyy', [Date::SEPARATOR_DASH, Date::SEPARATOR_SPACE], [Date::DAY_NUMBER_LONG, Date::MONTH_NUMBER_LONG, 'in the year', Date::YEAR_FULL]],
|
|
["yyyy-mm-dd\u{a0}(ddd)", [Date::SEPARATOR_DASH, Date::SEPARATOR_DASH, Date::SEPARATOR_SPACE_NONBREAKING, null], [Date::YEAR_FULL, Date::MONTH_NUMBER_LONG, Date::DAY_NUMBER_LONG, '(', Date::WEEKDAY_NAME_SHORT, ')']],
|
|
['yyyy-mm-dd', null, [Date::YEAR_FULL, Date::MONTH_NUMBER_LONG, Date::DAY_NUMBER_LONG]],
|
|
['yyyy-mm-dd'],
|
|
];
|
|
}
|
|
}
|