public function testTaskModification() { $c = new Config($this->container); $p = new Project($this->container); $tc = new TaskCreation($this->container); $tm = new TaskModification($this->container); $this->container['dispatcher']->addSubscriber(new WebhookSubscriber($this->container)); $c->save(array('webhook_url' => 'http://localhost/modif/')); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); $this->assertTrue($tm->update(array('id' => 1, 'title' => 'test update'))); $this->assertStringStartsWith('http://localhost/modif/?token=', $this->container['httpClient']->getUrl()); $event = $this->container['httpClient']->getData(); $this->assertNotEmpty($event); $this->assertArrayHasKey('event_name', $event); $this->assertArrayHasKey('event_data', $event); $this->assertEquals('task.update', $event['event_name']); $this->assertNotEmpty($event['event_data']); $this->assertArrayHasKey('project_id', $event['event_data']); $this->assertArrayHasKey('task_id', $event['event_data']); $this->assertArrayHasKey('title', $event['event_data']); $this->assertArrayHasKey('column_id', $event['event_data']); $this->assertArrayHasKey('color_id', $event['event_data']); $this->assertArrayHasKey('swimlane_id', $event['event_data']); $this->assertArrayHasKey('date_creation', $event['event_data']); $this->assertArrayHasKey('date_modification', $event['event_data']); $this->assertArrayHasKey('date_moved', $event['event_data']); $this->assertArrayHasKey('position', $event['event_data']); }
public function testCalculateTime() { $tm = new TaskModification($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); $s = new SubTask($this->container); $ts = new TimeTracking($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5))); $this->assertTrue($tm->update(array('id' => 1, 'time_spent' => 3.5))); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(4.5, $task['time_estimated']); $this->assertEquals(3.5, $task['time_spent']); $timesheet = $ts->getTaskTimesheet($task, array()); $this->assertNotEmpty($timesheet); $this->assertEquals(4.5, $timesheet['time_estimated']); $this->assertEquals(3.5, $timesheet['time_spent']); $this->assertEquals(1, $timesheet['time_remaining']); // Subtasks calculation $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_estimated' => 5.5, 'time_spent' => 3))); $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => '', 'time_spent' => 4))); $timesheet = $ts->getTaskTimesheet($task, $s->getAll(1)); $this->assertNotEmpty($timesheet); $this->assertEquals(5.5, $timesheet['time_estimated']); $this->assertEquals(7, $timesheet['time_spent']); $this->assertEquals(-1.5, $timesheet['time_remaining']); }
public function testChangeTimeSpent() { $p = new Project($this->container); $tc = new TaskCreation($this->container); $tm = new TaskModification($this->container); $tf = new TaskFinder($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); $task = $tf->getById(1); $this->assertEquals(0, $task['time_spent']); $this->assertTrue($tm->update(array('id' => 1, 'time_spent' => 13.3))); $task = $tf->getById(1); $this->assertEquals(13.3, $task['time_spent']); }