diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-07-07 19:15:53 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-07-07 19:15:53 -0400 |
commit | 58297ca3b11b9ad526a8ac344e5ac56d9e1b5a13 (patch) | |
tree | c20ff7b7463e0fa97667a2f17c482c85e015f7e3 /tests/units | |
parent | 5e7e03a866459047b677e57be33eee991aa57214 (diff) |
Add datetime picker for start date
Diffstat (limited to 'tests/units')
-rw-r--r-- | tests/units/DateParserTest.php | 6 | ||||
-rw-r--r-- | tests/units/TaskCreationTest.php | 30 | ||||
-rw-r--r-- | tests/units/TaskModificationTest.php | 18 |
3 files changed, 40 insertions, 14 deletions
diff --git a/tests/units/DateParserTest.php b/tests/units/DateParserTest.php index 9403063b..4b3e93c8 100644 --- a/tests/units/DateParserTest.php +++ b/tests/units/DateParserTest.php @@ -56,6 +56,12 @@ class DateParserTest extends Base $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'))); + $this->assertEquals('2014-03-25 17:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18 pm'))); + $this->assertEquals('2014-03-25 05:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18 am'))); + $this->assertEquals('2014-03-25 05:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18am'))); + $this->assertEquals('2014-03-25 23:14', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 23:14'))); + $this->assertEquals('2014-03-29 23:14', date('Y-m-d H:i', $d->getTimestamp('2014_03_29 23:14'))); + $this->assertEquals('2014-03-29 23:14', date('Y-m-d H:i', $d->getTimestamp('2014-03-29 23:14'))); } public function testConvert() diff --git a/tests/units/TaskCreationTest.php b/tests/units/TaskCreationTest.php index b3f001c7..3dd2b714 100644 --- a/tests/units/TaskCreationTest.php +++ b/tests/units/TaskCreationTest.php @@ -284,29 +284,35 @@ class TaskCreationTest extends Base public function testDateStarted() { - $date = '2014-11-23'; - $timestamp = strtotime('+2days'); $p = new Project($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); - $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $date))); - $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $timestamp))); + + // Set only a date + $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24'))); $task = $tf->getById(1); - $this->assertNotEmpty($task); - $this->assertNotFalse($task); + $this->assertEquals('2014-11-24 '.date('H:i'), date('Y-m-d H:i', $task['date_started'])); - $this->assertEquals(1, $task['id']); - $this->assertEquals($date, date('Y-m-d', $task['date_started'])); + // Set a datetime + $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24 16:25'))); $task = $tf->getById(2); - $this->assertNotEmpty($task); - $this->assertNotFalse($task); + $this->assertEquals('2014-11-24 16:25', date('Y-m-d H:i', $task['date_started'])); - $this->assertEquals(2, $task['id']); - $this->assertEquals($timestamp, $task['date_started']); + // Set a datetime + $this->assertEquals(3, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24 6:25pm'))); + + $task = $tf->getById(3); + $this->assertEquals('2014-11-24 18:25', date('Y-m-d H:i', $task['date_started'])); + + // Set a timestamp + $this->assertEquals(4, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => time()))); + + $task = $tf->getById(4); + $this->assertEquals(time(), $task['date_started'], '', 1); } public function testTime() diff --git a/tests/units/TaskModificationTest.php b/tests/units/TaskModificationTest.php index e6d8f8dc..4dd89c5e 100644 --- a/tests/units/TaskModificationTest.php +++ b/tests/units/TaskModificationTest.php @@ -202,15 +202,29 @@ class TaskModificationTest extends Base $task = $tf->getById(1); $this->assertEquals(0, $task['date_started']); + // Set only a date $this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24'))); $task = $tf->getById(1); - $this->assertEquals('2014-11-24', date('Y-m-d', $task['date_started'])); + $this->assertEquals('2014-11-24 '.date('H:i'), date('Y-m-d H:i', $task['date_started'])); + // Set a datetime + $this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24 16:25'))); + + $task = $tf->getById(1); + $this->assertEquals('2014-11-24 16:25', date('Y-m-d H:i', $task['date_started'])); + + // Set a datetime + $this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24 6:25pm'))); + + $task = $tf->getById(1); + $this->assertEquals('2014-11-24 18:25', date('Y-m-d H:i', $task['date_started'])); + + // Set a timestamp $this->assertTrue($tm->update(array('id' => 1, 'date_started' => time()))); $task = $tf->getById(1); - $this->assertEquals(date('Y-m-d'), date('Y-m-d', $task['date_started'])); + $this->assertEquals(time(), $task['date_started'], '', 1); } public function testChangeTimeEstimated() |