From 8f0e544cd91b24423951bbb5d3f3be0950a63abe Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 21 Nov 2014 21:41:26 -0500 Subject: Create TaskStatus model --- tests/units/TaskStatusTest.php | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/units/TaskStatusTest.php (limited to 'tests/units/TaskStatusTest.php') diff --git a/tests/units/TaskStatusTest.php b/tests/units/TaskStatusTest.php new file mode 100644 index 00000000..9b17ccd7 --- /dev/null +++ b/tests/units/TaskStatusTest.php @@ -0,0 +1,61 @@ +container); + $tf = new TaskFinder($this->container); + $ts = new TaskStatus($this->container); + $p = new Project($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1))); + + // The task must be open + + $this->assertTrue($ts->isOpen(1)); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); + $this->assertEquals(0, $task['date_completed']); + $this->assertEquals(time(), $task['date_modification']); + + // We close the task + + $ts->close(1); + + $this->assertTrue($ts->isClosed(1)); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(Task::STATUS_CLOSED, $task['is_active']); + $this->assertEquals(time(), $task['date_completed']); + $this->assertEquals(time(), $task['date_modification']); + + $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CLOSE)); + + // We open the task again + + $ts->open(1); + + $this->assertTrue($ts->isOpen(1)); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(Task::STATUS_OPEN, $task['is_active']); + $this->assertEquals(0, $task['date_completed']); + $this->assertEquals(time(), $task['date_modification']); + + $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_OPEN)); + } +} -- cgit v1.2.3