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
|
<?php
use Kanboard\Model\ProjectModel;
use Kanboard\Model\ProjectRoleModel;
require_once __DIR__.'/../Base.php';
class ProjectRoleModelTest extends Base
{
public function testCreation()
{
$projectModel = new ProjectModel($this->container);
$projectRoleModel = new ProjectRoleModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
$this->assertEquals(1, $projectRoleModel->create(1, 'my-custom-role'));
$this->assertFalse($projectRoleModel->create(1, 'my-custom-role'));
}
public function testGetAll()
{
$projectModel = new ProjectModel($this->container);
$projectRoleModel = new ProjectRoleModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
$this->assertEquals(1, $projectRoleModel->create(1, 'Role A'));
$this->assertEquals(2, $projectRoleModel->create(1, 'Role B'));
$roles = $projectRoleModel->getAll(1);
$this->assertCount(2, $roles);
$this->assertEquals(1, $roles[0]['role_id']);
$this->assertEquals('Role A', $roles[0]['role']);
$this->assertEquals(2, $roles[1]['role_id']);
$this->assertEquals('Role B', $roles[1]['role']);
}
public function testModification()
{
$projectModel = new ProjectModel($this->container);
$projectRoleModel = new ProjectRoleModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
$this->assertEquals(1, $projectRoleModel->create(1, 'Role A'));
$this->assertTrue($projectRoleModel->update(1, 1, 'Role B'));
}
public function testRemove()
{
$projectModel = new ProjectModel($this->container);
$projectRoleModel = new ProjectRoleModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
$this->assertEquals(1, $projectRoleModel->create(1, 'Role A'));
$this->assertTrue($projectRoleModel->remove(1, 1));
$this->assertEmpty($projectRoleModel->getAll(1));
}
}
|