Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.1 KiB

<?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));
}
}