diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-09-07 22:40:38 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-09-07 22:40:38 -0400 |
commit | dded773749e869893a00865cf2183a7f0c684038 (patch) | |
tree | 1162daf867bfb23289e0d8488b60a861d6bf9786 /tests/units/Model/ProjectRoleModelTest.php | |
parent | 102de7e3860929e62578a6c96f810252dc572bdf (diff) |
Add new models ColumnMoveRestrictionModel and ProjectRoleModel
Diffstat (limited to 'tests/units/Model/ProjectRoleModelTest.php')
-rw-r--r-- | tests/units/Model/ProjectRoleModelTest.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/units/Model/ProjectRoleModelTest.php b/tests/units/Model/ProjectRoleModelTest.php new file mode 100644 index 00000000..ce1392c2 --- /dev/null +++ b/tests/units/Model/ProjectRoleModelTest.php @@ -0,0 +1,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)); + } +} |