summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Model/ProjectModelTest.php68
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);