Added API calls for subtask time tracking

This commit is contained in:
Frederic Guillot
2016-06-26 15:47:02 -04:00
parent f621129836
commit 82623f1a21
7 changed files with 165 additions and 16 deletions

View File

@@ -17,6 +17,7 @@ abstract class BaseProcedureTest extends PHPUnit_Framework_TestCase
protected $projectId = 0;
protected $taskTitle = 'My task';
protected $taskId = 0;
protected $subtaskId = 0;
protected $groupName1 = 'My Group A';
protected $groupName2 = 'My Group B';
@@ -119,4 +120,14 @@ abstract class BaseProcedureTest extends PHPUnit_Framework_TestCase
$this->taskId = $this->app->createTask(array('title' => $this->taskTitle, 'project_id' => $this->projectId));
$this->assertNotFalse($this->taskId);
}
public function assertCreateSubtask()
{
$this->subtaskId = $this->app->createSubtask(array(
'task_id' => $this->taskId,
'title' => 'subtask #1',
));
$this->assertNotFalse($this->subtaskId);
}
}

View File

@@ -5,7 +5,6 @@ require_once __DIR__.'/BaseProcedureTest.php';
class SubtaskProcedureTest extends BaseProcedureTest
{
protected $projectName = 'My project to test subtasks';
private $subtaskId = 0;
public function testAll()
{
@@ -18,16 +17,6 @@ class SubtaskProcedureTest extends BaseProcedureTest
$this->assertRemoveSubtask();
}
public function assertCreateSubtask()
{
$this->subtaskId = $this->app->createSubtask(array(
'task_id' => $this->taskId,
'title' => 'subtask #1',
));
$this->assertNotFalse($this->subtaskId);
}
public function assertGetSubtask()
{
$subtask = $this->app->getSubtask($this->subtaskId);

View File

@@ -0,0 +1,46 @@
<?php
require_once __DIR__.'/BaseProcedureTest.php';
class SubtaskTimeTrackingProcedureTest extends BaseProcedureTest
{
protected $projectName = 'My project to test subtask time tracking';
public function testAll()
{
$this->assertCreateTeamProject();
$this->assertCreateTask();
$this->assertCreateSubtask();
$this->assertHasNoTimer();
$this->assertStartTimer();
$this->assertHasTimer();
$this->assertStopTimer();
$this->assertHasNoTimer();
$this->assertGetSubtaskTimeSpent();
}
public function assertHasNoTimer()
{
$this->assertFalse($this->app->hasSubtaskTimer($this->subtaskId, $this->userUserId));
}
public function assertHasTimer()
{
$this->assertTrue($this->app->hasSubtaskTimer($this->subtaskId, $this->userUserId));
}
public function assertStartTimer()
{
$this->assertTrue($this->app->setSubtaskStartTime($this->subtaskId, $this->userUserId));
}
public function assertStopTimer()
{
$this->assertTrue($this->app->setSubtaskEndTime($this->subtaskId, $this->userUserId));
}
public function assertGetSubtaskTimeSpent()
{
$this->assertEquals(0, $this->app->getSubtaskTimeSpent($this->subtaskId, $this->userUserId));
}
}