Rewrite integration tests to run with Docker containers
This commit is contained in:
@@ -1,132 +1,55 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/Base.php';
|
||||
require_once __DIR__.'/BaseIntegrationTest.php';
|
||||
|
||||
class TaskTest extends Base
|
||||
class TaskTest extends BaseIntegrationTest
|
||||
{
|
||||
public function testSearchTasks()
|
||||
protected $projectName = 'My project to test tasks';
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$project_id1 = $this->app->createProject('My project');
|
||||
$project_id2 = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id1);
|
||||
$this->assertNotFalse($project_id2);
|
||||
|
||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T1')));
|
||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T2')));
|
||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id2, 'title' => 'T3')));
|
||||
|
||||
$tasks = $this->app->searchTasks($project_id1, 't2');
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('T2', $tasks[0]['title']);
|
||||
|
||||
$tasks = $this->app->searchTasks(array('project_id' => $project_id2, 'query' => 'assignee:nobody'));
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('T3', $tasks[0]['title']);
|
||||
$this->assertCreateTeamProject();
|
||||
$this->assertCreateTask();
|
||||
$this->assertUpdateTask();
|
||||
$this->assertGetTaskById();
|
||||
$this->assertGetTaskByReference();
|
||||
$this->assertGetAllTasks();
|
||||
$this->assertOpenCloseTask();
|
||||
}
|
||||
|
||||
public function testPriorityAttribute()
|
||||
public function assertUpdateTask()
|
||||
{
|
||||
$project_id = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id);
|
||||
|
||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'priority' => 2));
|
||||
|
||||
$task = $this->app->getTask($task_id);
|
||||
$this->assertEquals(2, $task['priority']);
|
||||
|
||||
$this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'priority' => 3)));
|
||||
|
||||
$task = $this->app->getTask($task_id);
|
||||
$this->assertEquals(3, $task['priority']);
|
||||
$this->assertTrue($this->app->updateTask(array('id' => $this->taskId, 'color_id' => 'red')));
|
||||
}
|
||||
|
||||
public function testChangeAssigneeToAssignableUser()
|
||||
public function assertGetTaskById()
|
||||
{
|
||||
$project_id = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id);
|
||||
|
||||
$user_id = $this->app->createUser('user0', 'password');
|
||||
$this->assertNotFalse($user_id);
|
||||
|
||||
$this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member'));
|
||||
|
||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task'));
|
||||
$this->assertNotFalse($task_id);
|
||||
|
||||
$this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => $user_id)));
|
||||
|
||||
$task = $this->app->getTask($task_id);
|
||||
$this->assertEquals($user_id, $task['owner_id']);
|
||||
$task = $this->app->getTask($this->taskId);
|
||||
$this->assertNotNull($task);
|
||||
$this->assertEquals('red', $task['color_id']);
|
||||
$this->assertEquals($this->taskTitle, $task['title']);
|
||||
}
|
||||
|
||||
public function testChangeAssigneeToNotAssignableUser()
|
||||
public function assertGetTaskByReference()
|
||||
{
|
||||
$project_id = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id);
|
||||
$taskId = $this->app->createTask(array('title' => 'task with reference', 'project_id' => $this->projectId, 'reference' => 'test'));
|
||||
$this->assertNotFalse($taskId);
|
||||
|
||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task'));
|
||||
$this->assertNotFalse($task_id);
|
||||
|
||||
$this->assertFalse($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 1)));
|
||||
|
||||
$task = $this->app->getTask($task_id);
|
||||
$this->assertEquals(0, $task['owner_id']);
|
||||
$task = $this->app->getTaskByReference($this->projectId, 'test');
|
||||
$this->assertNotNull($task);
|
||||
$this->assertEquals($taskId, $task['id']);
|
||||
}
|
||||
|
||||
public function testChangeAssigneeToNobody()
|
||||
public function assertGetAllTasks()
|
||||
{
|
||||
$project_id = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id);
|
||||
|
||||
$user_id = $this->app->createUser('user1', 'password');
|
||||
$this->assertNotFalse($user_id);
|
||||
|
||||
$this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member'));
|
||||
|
||||
$task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'owner_id' => $user_id));
|
||||
$this->assertNotFalse($task_id);
|
||||
|
||||
$this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 0)));
|
||||
|
||||
$task = $this->app->getTask($task_id);
|
||||
$this->assertEquals(0, $task['owner_id']);
|
||||
$tasks = $this->app->getAllTasks($this->projectId);
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertNotEmpty($tasks);
|
||||
}
|
||||
|
||||
public function testMoveTaskToAnotherProject()
|
||||
public function assertOpenCloseTask()
|
||||
{
|
||||
$project_id1 = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id1);
|
||||
|
||||
$project_id2 = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id2);
|
||||
|
||||
$task_id = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task'));
|
||||
$this->assertNotFalse($task_id);
|
||||
|
||||
$this->assertTrue($this->app->moveTaskToProject($task_id, $project_id2));
|
||||
|
||||
$task = $this->app->getTask($task_id);
|
||||
$this->assertEquals($project_id2, $task['project_id']);
|
||||
}
|
||||
|
||||
public function testMoveCopyToAnotherProject()
|
||||
{
|
||||
$project_id1 = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id1);
|
||||
|
||||
$project_id2 = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id2);
|
||||
|
||||
$task_id1 = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task'));
|
||||
$this->assertNotFalse($task_id1);
|
||||
|
||||
$task_id2 = $this->app->duplicateTaskToProject($task_id1, $project_id2);
|
||||
$this->assertNotFalse($task_id2);
|
||||
|
||||
$task = $this->app->getTask($task_id1);
|
||||
$this->assertEquals($project_id1, $task['project_id']);
|
||||
|
||||
$task = $this->app->getTask($task_id2);
|
||||
$this->assertEquals($project_id2, $task['project_id']);
|
||||
$this->assertTrue($this->app->closeTask($this->taskId));
|
||||
$this->assertTrue($this->app->openTask($this->taskId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user