summaryrefslogtreecommitdiff
path: root/tests/integration/TaskLinkProcedureTest.php
blob: a25fced547fb17a83f0a5ed9c708e9445b3baedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

require_once __DIR__.'/BaseProcedureTest.php';

class TaskLinkProcedureTest extends BaseProcedureTest
{
    protected $projectName = 'My project to test task links';
    protected $taskLinkId;
    protected $taskId1;
    protected $taskId2;

    public function testAll()
    {
        $this->assertCreateTeamProject();

        $this->taskId1 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 1'));
        $this->taskId2 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 2'));

        $this->assertNotFalse($this->taskId1);
        $this->assertNotFalse($this->taskId2);

        $this->assertCreateTaskLink();
        $this->assertGetTaskLink();
        $this->assertGetAllTaskLinks();
        $this->assertUpdateTaskLink();
        $this->assertRemoveTaskLink();
    }

    public function assertCreateTaskLink()
    {
        $this->taskLinkId = $this->app->createTaskLink($this->taskId1, $this->taskId2, 1);
        $this->assertNotFalse($this->taskLinkId);
    }

    public function assertGetTaskLink()
    {
        $link = $this->app->getTaskLinkById($this->taskLinkId);
        $this->assertNotNull($link);
        $this->assertEquals($this->taskId1, $link['task_id']);
        $this->assertEquals($this->taskId2, $link['opposite_task_id']);
        $this->assertEquals(1, $link['link_id']);
    }

    public function assertGetAllTaskLinks()
    {
        $links = $this->app->getAllTaskLinks($this->taskId2);
        $this->assertCount(1, $links);
    }

    public function assertUpdateTaskLink()
    {
        $this->assertTrue($this->app->updateTaskLink($this->taskLinkId, $this->taskId1, $this->taskId2, 3));

        $link = $this->app->getTaskLinkById($this->taskLinkId);
        $this->assertNotNull($link);
        $this->assertEquals($this->taskId1, $link['task_id']);
        $this->assertEquals($this->taskId2, $link['opposite_task_id']);
        $this->assertEquals(3, $link['link_id']);
    }

    public function assertRemoveTaskLink()
    {
        $this->assertTrue($this->app->removeTaskLink($this->taskLinkId));

        $links = $this->app->getAllTaskLinks($this->taskId2);
        $this->assertCount(0, $links);
    }
}