]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/DateTimeFormatTest.php
Merge pull request #7765 from nupplaphil/task/move_text
[friendica.git] / tests / src / Util / DateTimeFormatTest.php
diff --git a/tests/src/Util/DateTimeFormatTest.php b/tests/src/Util/DateTimeFormatTest.php
new file mode 100644 (file)
index 0000000..bdc902e
--- /dev/null
@@ -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));
+       }
+}