mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 14:55:44 +01:00
Improves SPDX header linting to ensure consistent license metadata across the codebase. Key changes: - Enforce deterministic tag ordering (License-Identifier, FileCopyrightText, FileContributor) to ensure consistency, prevent merge conflicts, and simplify code reviews - Add contributor alias mapping to consolidate contributors with multiple emails or name variations (e.g., "nickl-" → "Nick Lombard") - Add --contributions-strategy option with "blame" (current code authors) and "log" (all historical contributors) to support different attribution philosophies - Add optional path argument to lint specific files or directories - Add --fix option to automatically correct header issues Assisted-by: Claude Code (claude-opus-4-5-20251101)
72 lines
2.3 KiB
PHP
72 lines
2.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-FileContributor: Davide Spagnoli <davide.spagnoli@adam-italia.it>
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
* SPDX-FileContributor: agchan12 <andrew.chan@bigcommerce.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Helpers;
|
|
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Respect\Validation\Test\TestCase;
|
|
|
|
#[Group('helper')]
|
|
final class CanValidateDateTimeTest extends TestCase
|
|
{
|
|
use CanValidateDateTime;
|
|
|
|
#[Test]
|
|
#[DataProvider('providerForValidDateTime')]
|
|
public function shouldFindWhenValueIsDateTime(string $format, string $value): void
|
|
{
|
|
self::assertTrue($this->isDateTime($format, $value));
|
|
}
|
|
|
|
#[Test]
|
|
#[DataProvider('providerForInvalidDateTime')]
|
|
public function shouldFindWhenValueIsNotDateTime(string $format, string $value): void
|
|
{
|
|
self::assertFalse($this->isDateTime($format, $value));
|
|
}
|
|
|
|
/** @return mixed[][] */
|
|
public static function providerForValidDateTime(): array
|
|
{
|
|
return [
|
|
'overflow days' => ['m-Y', '02-2025'],
|
|
['Y-m-d', '2009-09-09'],
|
|
['Y-m-d', '2020-02-29'],
|
|
['Ymd', '20090909'],
|
|
['d/m/Y', '23/05/1987'],
|
|
['c', '2018-01-30T19:04:35+00:00'],
|
|
['Y-m-d\TH:i:sP', '2018-01-30T19:04:35+00:00'],
|
|
['r', 'Tue, 30 Jan 2018 19:06:01 +0000'],
|
|
['D, d M Y H:i:s O', 'Tue, 30 Jan 2018 19:06:01 +0000'],
|
|
];
|
|
}
|
|
|
|
/** @return mixed[][] */
|
|
public static function providerForInvalidDateTime(): array
|
|
{
|
|
return [
|
|
['Y-m-d', '0000-01-01'],
|
|
['Y-m-d', '2021-02-29'],
|
|
['y-m-d', '2009-09-12'],
|
|
['Y-m-d', '0000-00-31'],
|
|
['Y-m-d', '0000-12-00'],
|
|
['Y-m-d H:i:s', '1987-12-31'],
|
|
['c', '2018-01-30T19:04:35-00:00'],
|
|
['Y-m-d\TH:i:sP', '2018-01-30T19:04:35-00:00'],
|
|
['r', 'Tue, 30 Jan 2018 19:06:01 -0000'],
|
|
['D, d M Y H:i:s O', 'Tue, 30 Jan 2018 19:06:01 -0000'],
|
|
];
|
|
}
|
|
}
|