diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-09-20 11:58:27 +0200 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-09-20 11:58:27 +0200 |
commit | 5f96af82f26967f4614b89322a82a59cb48bd2a3 (patch) | |
tree | 98f527458d27f325cec7419dbb033b8f9f5f8b20 /tests/units/DateParserTest.php | |
parent | 95e54d1d300809cb8656c52d029f797ba5961a04 (diff) |
Split Task model into smaller classes
Diffstat (limited to 'tests/units/DateParserTest.php')
-rw-r--r-- | tests/units/DateParserTest.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/units/DateParserTest.php b/tests/units/DateParserTest.php new file mode 100644 index 00000000..68addf3f --- /dev/null +++ b/tests/units/DateParserTest.php @@ -0,0 +1,32 @@ +<?php + +require_once __DIR__.'/Base.php'; + +use Model\DateParser; + +class DateParserTest extends Base +{ + public function testValidDate() + { + $d = new DateParser($this->registry); + + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('2014-03-05', 'Y-m-d'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('2014_03_05', 'Y_m_d'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('05/03/2014', 'd/m/Y'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('03/05/2014', 'm/d/Y'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('3/5/2014', 'm/d/Y'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('5/3/2014', 'd/m/Y'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('5/3/14', 'd/m/y'))); + $this->assertEquals(0, $d->getValidDate('5/3/14', 'd/m/Y')); + $this->assertEquals(0, $d->getValidDate('5-3-2014', 'd/m/Y')); + } + + public function testGetTimestamp() + { + $d = new DateParser($this->registry); + + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014-03-05'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014_03_05'))); + $this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('03/05/2014'))); + } +} |