diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-05-12 16:26:11 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-05-12 16:26:11 -0400 |
commit | 3cf9484644dc5002b396eb31a2065456ce0de5b7 (patch) | |
tree | 65ca672cb7d8cf5510531b2eb87c24ec5b6fb798 /tests | |
parent | 5b7e137f769e352e0dddeff6c0c9a19602a8e4d9 (diff) |
Ensure project tags are removed when the project is removed (PR #3250)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Model/ProjectModelTest.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/units/Model/ProjectModelTest.php b/tests/units/Model/ProjectModelTest.php index 03ba708e..fd247ffe 100644 --- a/tests/units/Model/ProjectModelTest.php +++ b/tests/units/Model/ProjectModelTest.php @@ -2,7 +2,13 @@ require_once __DIR__.'/../Base.php'; +use Kanboard\Api\Procedure\ProjectPermissionProcedure; +use Kanboard\Core\Security\Role; use Kanboard\Core\Translator; +use Kanboard\Model\ColumnModel; +use Kanboard\Model\ProjectPermissionModel; +use Kanboard\Model\SwimlaneModel; +use Kanboard\Model\TagModel; use Kanboard\Subscriber\ProjectModificationDateSubscriber; use Kanboard\Model\ProjectModel; use Kanboard\Model\UserModel; @@ -207,6 +213,68 @@ class ProjectModelTest extends Base $this->assertFalse($projectModel->remove(1234)); } + public function testRemoveTagsOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $tagModel = new TagModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertNotFalse($tagModel->create(1, 'TestTag')); + + $this->assertCount(1, $tagModel->getAllByProject(1)); + + $this->assertTrue($projectModel->remove(1)); + + $this->assertCount(0, $tagModel->getAllByProject(1)); + } + + public function testRemoveSwimlaneOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $swimlaneModel = new SwimlaneModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $swimlaneId = $swimlaneModel->create(1, 'TestSwimlane'); + $this->assertNotFalse($swimlaneId); + + $this->assertTrue($projectModel->remove(1)); + $this->assertNull($swimlaneModel->getById($swimlaneId)); + } + + public function testRemoveColumnOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $columnModel = new ColumnModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $columnId = $columnModel->create(1, 'TestColumn'); + $this->assertNotFalse($columnId); + + $this->assertTrue($projectModel->remove(1)); + $this->assertNull($columnModel->getById($columnId)); + } + + public function testRemovePermissionOnProjectRemove() + { + $projectModel = new ProjectModel($this->container); + $userModel = new UserModel($this->container); + + $permissionModel = new ProjectPermissionModel($this->container); + $permissionProcedure = new ProjectPermissionProcedure($this->container); + + $userId = $userModel->create(array('username' => 'user1')); + $this->assertNotFalse($userId); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $permissionProcedure->addProjectUser(1, $userId, Role::PROJECT_MEMBER); + + $this->assertTrue($permissionModel->isUserAllowed(1, $userId)); + $this->assertTrue($projectModel->remove(1)); + $this->assertFalse($permissionModel->isUserAllowed(1, $userId)); + } + public function testEnable() { $projectModel = new ProjectModel($this->container); |