]> git.mxchange.org Git - friendica.git/blob - tests/src/Util/DateTimeFormatTest.php
Merge pull request #7785 from nupplaphil/bug/7676-is_file_warning
[friendica.git] / tests / src / Util / DateTimeFormatTest.php
1 <?php
2
3 namespace Friendica\Test\src\Util;
4
5 use Friendica\Test\MockedTest;
6 use Friendica\Util\DateTimeFormat;
7
8 class DateTimeFormatTest extends MockedTest
9 {
10         public function dataYearMonth()
11         {
12                 return [
13                         'validNormal' => [
14                                 'input' => '1990-10',
15                                 'assert' => true,
16                         ],
17                         'validOneCharMonth' => [
18                                 'input' => '1990-1',
19                                 'assert' => true,
20                         ],
21                         'validTwoCharMonth' => [
22                                 'input' => '1990-01',
23                                 'assert' => true,
24                         ],
25                         'invalidFormat' => [
26                                 'input' => '199-11',
27                                 'assert' => false,
28                         ],
29                         'invalidFormat2' => [
30                                 'input' => '1990-15',
31                                 'assert' => false,
32                         ],
33                         'invalidFormat3' => [
34                                 'input' => '99-101',
35                                 'assert' => false,
36                         ],
37                         'invalidFormat4' => [
38                                 'input' => '11-1990',
39                                 'assert' => false,
40                         ],
41                         'invalidFuture' => [
42                                 'input' => '3030-12',
43                                 'assert' => false,
44                         ],
45                         'invalidYear' => [
46                                 'input' => '-100-10',
47                                 'assert' => false,
48                         ],
49                 ];
50         }
51
52         /**
53          * @dataProvider dataYearMonth
54          */
55         public function testIsYearMonth(string $input, bool $assert)
56         {
57                 $dtFormat = new DateTimeFormat();
58
59                 $this->assertEquals($assert, $dtFormat->isYearMonth($input));
60         }
61 }