mirror of
https://github.com/friendica/friendica
synced 2025-04-26 06:30:11 +00:00
Move is_a_date_arg to DateTimeFormat::isYearMonth
- Improved functionality - Added tests
This commit is contained in:
parent
52c42491c4
commit
ad67fd3aa8
5 changed files with 107 additions and 22 deletions
61
tests/src/Util/DateTimeFormatTest.php
Normal file
61
tests/src/Util/DateTimeFormatTest.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Util;
|
||||
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
class DateTimeFormatTest extends MockedTest
|
||||
{
|
||||
public function dataYearMonth()
|
||||
{
|
||||
return [
|
||||
'validNormal' => [
|
||||
'input' => '1990-10',
|
||||
'assert' => true,
|
||||
],
|
||||
'validOneCharMonth' => [
|
||||
'input' => '1990-1',
|
||||
'assert' => true,
|
||||
],
|
||||
'validTwoCharMonth' => [
|
||||
'input' => '1990-01',
|
||||
'assert' => true,
|
||||
],
|
||||
'invalidFormat' => [
|
||||
'input' => '199-11',
|
||||
'assert' => false,
|
||||
],
|
||||
'invalidFormat2' => [
|
||||
'input' => '1990-15',
|
||||
'assert' => false,
|
||||
],
|
||||
'invalidFormat3' => [
|
||||
'input' => '99-101',
|
||||
'assert' => false,
|
||||
],
|
||||
'invalidFormat4' => [
|
||||
'input' => '11-1990',
|
||||
'assert' => false,
|
||||
],
|
||||
'invalidFuture' => [
|
||||
'input' => '3030-12',
|
||||
'assert' => false,
|
||||
],
|
||||
'invalidYear' => [
|
||||
'input' => '-100-10',
|
||||
'assert' => false,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataYearMonth
|
||||
*/
|
||||
public function testIsYearMonth(string $input, bool $assert)
|
||||
{
|
||||
$dtFormat = new DateTimeFormat();
|
||||
|
||||
$this->assertEquals($assert, $dtFormat->isYearMonth($input));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue