summaryrefslogtreecommitdiff
path: root/tests/integration/ProjectProcedureTest.php
blob: 69c2464fd1cd536d8bd319574e8de88fdcbf4a2c (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php

require_once __DIR__.'/BaseProcedureTest.php';

class ProjectProcedureTest extends BaseProcedureTest
{
    protected $projectName = 'My team project';

    public function testAll()
    {
        $this->assertCreateTeamProject();
        $this->assertGetProjectById();
        $this->assertGetProjectByName();
        $this->assertGetAllProjects();
        $this->assertUpdateProject();
        $this->assertUpdateProjectIdentifier();
        $this->assertCreateProjectWithIdentifier();
        $this->assertGetProjectActivity();
        $this->assertGetProjectsActivity();
        $this->assertEnableDisableProject();
        $this->assertEnableDisablePublicAccess();
        $this->assertRemoveProject();
    }

    public function assertGetProjectById()
    {
        $project = $this->app->getProjectById($this->projectId);
        $this->assertNotNull($project);
        $this->assertEquals($this->projectName, $project['name']);
        $this->assertEquals('Description', $project['description']);
    }

    public function assertGetProjectByName()
    {
        $project = $this->app->getProjectByName($this->projectName);
        $this->assertNotNull($project);
        $this->assertEquals($this->projectId, $project['id']);
        $this->assertEquals($this->projectName, $project['name']);
        $this->assertEquals('Description', $project['description']);
    }

    public function assertGetAllProjects()
    {
        $projects = $this->app->getAllProjects();
        $this->assertNotEmpty($projects);
    }

    public function assertGetProjectActivity()
    {
        $activities = $this->app->getProjectActivity($this->projectId);
        $this->assertInternalType('array', $activities);
        $this->assertCount(0, $activities);
    }

    public function assertGetProjectsActivity()
    {
        $activities = $this->app->getProjectActivities(array('project_ids' => array($this->projectId)));
        $this->assertInternalType('array', $activities);
        $this->assertCount(0, $activities);
    }

    public function assertUpdateProject()
    {
        $this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => 'test', 'description' => 'test')));

        $project = $this->app->getProjectById($this->projectId);
        $this->assertNotNull($project);
        $this->assertEquals('test', $project['name']);
        $this->assertEquals('test', $project['description']);

        $this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => $this->projectName)));
    }

    public function assertUpdateProjectIdentifier()
    {
        $this->assertTrue($this->app->updateProject(array(
            'project_id' => $this->projectId,
            'identifier' => 'MYPROJECT',
        )));

        $project = $this->app->getProjectById($this->projectId);
        $this->assertNotNull($project);
        $this->assertEquals($this->projectName, $project['name']);
        $this->assertEquals('MYPROJECT', $project['identifier']);
    }

    public function assertCreateProjectWithIdentifier()
    {
        $projectId = $this->app->createProject(array(
            'name' => 'My project with an identifier',
            'identifier' => 'MYPROJECTWITHIDENTIFIER',
        ));

        $this->assertNotFalse($projectId);

        $project = $this->app->getProjectByIdentifier('MYPROJECTWITHIDENTIFIER');
        $this->assertEquals($projectId, $project['id']);
        $this->assertEquals('My project with an identifier', $project['name']);
        $this->assertEquals('MYPROJECTWITHIDENTIFIER', $project['identifier']);
    }

    public function assertEnableDisableProject()
    {
        $this->assertTrue($this->app->disableProject($this->projectId));
        $this->assertTrue($this->app->enableProject($this->projectId));
    }

    public function assertEnableDisablePublicAccess()
    {
        $this->assertTrue($this->app->disableProjectPublicAccess($this->projectId));
        $this->assertTrue($this->app->enableProjectPublicAccess($this->projectId));
    }

    public function assertRemoveProject()
    {
        $this->assertTrue($this->app->removeProject($this->projectId));
        $this->assertNull($this->app->getProjectById($this->projectId));
    }
}