コード例 #1
0
 public function testHandlePayload()
 {
     $w = new EmailHandler($this->container);
     $p = new Project($this->container);
     $pp = new ProjectUserRole($this->container);
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost')));
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
     // Empty payload
     $this->assertFalse($w->receiveEmail(array()));
     // Unknown user
     $this->assertFalse($w->receiveEmail(array('sender' => 'a@b.c', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo')));
     // Project not found
     $this->assertFalse($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo')));
     // User is not member
     $this->assertFalse($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
     $this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));
     // The task must be created
     $this->assertTrue($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-html' => '<strong>boo</strong>')));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**boo**', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
 }
コード例 #2
0
 public function testDuplicate()
 {
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $groupModel = new Group($this->container);
     $groupMemberModel = new GroupMember($this->container);
     $groupRoleModel = new ProjectGroupRole($this->container);
     $userRoleModel = new ProjectUserRole($this->container);
     $projectPermission = new ProjectPermission($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1')));
     $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2')));
     $this->assertEquals(2, $userModel->create(array('username' => 'user 1', 'name' => 'User #1')));
     $this->assertEquals(3, $userModel->create(array('username' => 'user 2')));
     $this->assertEquals(4, $userModel->create(array('username' => 'user 3')));
     $this->assertEquals(5, $userModel->create(array('username' => 'user 4')));
     $this->assertEquals(6, $userModel->create(array('username' => 'user 5', 'name' => 'User #5')));
     $this->assertEquals(1, $groupModel->create('Group C'));
     $this->assertEquals(2, $groupModel->create('Group B'));
     $this->assertEquals(3, $groupModel->create('Group A'));
     $this->assertTrue($groupMemberModel->addUser(1, 4));
     $this->assertTrue($groupMemberModel->addUser(2, 5));
     $this->assertTrue($groupMemberModel->addUser(3, 3));
     $this->assertTrue($groupMemberModel->addUser(3, 2));
     $this->assertTrue($groupRoleModel->addGroup(1, 1, Role::PROJECT_VIEWER));
     $this->assertTrue($groupRoleModel->addGroup(1, 3, Role::PROJECT_MANAGER));
     $this->assertTrue($userRoleModel->addUser(1, 5, Role::PROJECT_MANAGER));
     $this->assertTrue($userRoleModel->addUser(1, 6, Role::PROJECT_MEMBER));
     $this->assertTrue($projectPermission->duplicate(1, 2));
     $this->assertCount(2, $userRoleModel->getUsers(2));
     $this->assertCount(3, $groupRoleModel->getUsers(2));
 }
コード例 #3
0
 public function testGetProjectMembersWithNotifications()
 {
     $u = new User($this->container);
     $p = new Project($this->container);
     $n = new UserNotification($this->container);
     $pp = new ProjectUserRole($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     // Email + Notifications enabled
     $this->assertNotFalse($u->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1)));
     // No email + Notifications enabled
     $this->assertNotFalse($u->create(array('username' => 'user2', 'email' => '', 'notifications_enabled' => 1)));
     // Email + Notifications enabled
     $this->assertNotFalse($u->create(array('username' => 'user3', 'email' => 'user3@here', 'notifications_enabled' => 1)));
     // No email + notifications disabled
     $this->assertNotFalse($u->create(array('username' => 'user4')));
     // Nobody is member of any projects
     $this->assertEmpty($pp->getUsers(1));
     $this->assertEmpty($n->getUsersWithNotificationEnabled(1));
     // We allow all users to be member of our projects
     $this->assertTrue($pp->addUser(1, 1, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(1, 3, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(1, 4, Role::PROJECT_MEMBER));
     $this->assertNotEmpty($pp->getUsers(1));
     $users = $n->getUsersWithNotificationEnabled(1);
     $this->assertNotEmpty($users);
     $this->assertCount(3, $users);
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('', $users[1]['email']);
     $this->assertEquals('user3@here', $users[2]['email']);
 }
コード例 #4
0
 public function testFireEventsWithNoProjectId()
 {
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $projectModel = new Project($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $userModel = new User($this->container);
     $userMentionModel = new UserMention($this->container);
     $event = new GenericEvent(array('task_id' => 1));
     $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User 1', 'notifications_enabled' => 1)));
     $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User 2', 'notifications_enabled' => 1)));
     $this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
     $this->assertTrue($projectUserRoleModel->addUser(1, 3, Role::PROJECT_MEMBER));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'Task 1')));
     $this->container['dispatcher']->addListener(Task::EVENT_USER_MENTION, array($this, 'onUserMention'));
     $userMentionModel->fireEvents('test @user1 @user2', Task::EVENT_USER_MENTION, $event);
     $called = $this->container['dispatcher']->getCalledListeners();
     $this->assertArrayHasKey(Task::EVENT_USER_MENTION . '.UserMentionTest::onUserMention', $called);
 }
コード例 #5
0
 public function testChangeUser()
 {
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $taskFinderModel = new TaskFinder($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 0)));
     $this->assertEquals(2, $userModel->create(array('username' => 'user1')));
     $this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MEMBER));
     $event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'owner_id' => 2));
     $action = new TaskAssignUser($this->container);
     $action->setProjectId(1);
     $action->addEvent('test.event', 'Test Event');
     $this->assertTrue($action->execute($event, 'test.event'));
     $task = $taskFinderModel->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['owner_id']);
 }
コード例 #6
0
 public function testSuccess()
 {
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $commentModel = new Comment($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $this->assertEquals(2, $userModel->create(array('username' => 'user1')));
     $this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MEMBER));
     $event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'comment' => 'test123', 'reference' => 'ref123', 'user_id' => 2));
     $action = new CommentCreation($this->container);
     $action->setProjectId(1);
     $action->addEvent('test.event', 'Test Event');
     $this->assertTrue($action->execute($event, 'test.event'));
     $comment = $commentModel->getById(1);
     $this->assertNotEmpty($comment);
     $this->assertEquals(1, $comment['task_id']);
     $this->assertEquals('test123', $comment['comment']);
     $this->assertEquals('ref123', $comment['reference']);
     $this->assertEquals(2, $comment['user_id']);
 }
コード例 #7
0
 public function testBuild()
 {
     $projectModel = new Project($this->container);
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $userModel = new User($this->container);
     $userDistributionModel = new UserDistributionAnalytic($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(2, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(2, $userModel->create(array('username' => 'user1')));
     $this->assertEquals(3, $userModel->create(array('username' => 'user2')));
     $this->assertEquals(4, $userModel->create(array('username' => 'user3')));
     $this->assertEquals(5, $userModel->create(array('username' => 'user4')));
     $this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MEMBER));
     $this->assertTrue($projectUserRoleModel->addUser(1, 3, Role::PROJECT_MEMBER));
     $this->assertTrue($projectUserRoleModel->addUser(1, 4, Role::PROJECT_MEMBER));
     $this->assertTrue($projectUserRoleModel->addUser(1, 5, Role::PROJECT_MEMBER));
     $this->createTasks(0, 10, 1);
     $this->createTasks(2, 30, 1);
     $this->createTasks(3, 40, 1);
     $this->createTasks(4, 10, 1);
     $this->createTasks(5, 10, 1);
     $expected = array(array('user' => 'Unassigned', 'nb_tasks' => 10, 'percentage' => 10.0), array('user' => 'user1', 'nb_tasks' => 30, 'percentage' => 30.0), array('user' => 'user2', 'nb_tasks' => 40, 'percentage' => 40.0), array('user' => 'user3', 'nb_tasks' => 10, 'percentage' => 10.0), array('user' => 'user4', 'nb_tasks' => 10, 'percentage' => 10.0));
     $this->assertEquals($expected, $userDistributionModel->build(1));
 }
コード例 #8
0
 public function testMoveAnotherProjectWithForbiddenUser()
 {
     $td = new TaskDuplication($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $pp = new ProjectUserRole($this->container);
     $user = new User($this->container);
     // We create 2 projects
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2')));
     // We create a new user for our project
     $this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));
     // We create a task
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 3)));
     // We move our task to the 2nd project
     $this->assertTrue($td->moveToProject(1, 2));
     // Check the values of the moved task
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals(6, $task['column_id']);
 }
コード例 #9
0
 public function testCloneProjectWithUsers()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectUserRole($this->container);
     $u = new User($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest')));
     $this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest')));
     $this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest')));
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(1, 3, Role::PROJECT_MEMBER));
     $this->assertTrue($pp->addUser(1, 4, Role::PROJECT_MANAGER));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(1, 2));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(1, 3));
     $this->assertEquals(Role::PROJECT_MANAGER, $pp->getUserRole(1, 4));
     $this->assertEquals(2, $pd->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('P1 (Clone)', $project['name']);
     $this->assertEquals(3, count($pp->getUsers(2)));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(2, 2));
     $this->assertEquals(Role::PROJECT_MEMBER, $pp->getUserRole(2, 3));
     $this->assertEquals(Role::PROJECT_MANAGER, $pp->getUserRole(2, 4));
 }
コード例 #10
0
 public function testCommentCreatedWithUser()
 {
     $this->container['dispatcher']->addListener(GitlabWebhook::EVENT_ISSUE_COMMENT, array($this, 'onCommentCreatedWithUser'));
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'foobar')));
     $tc = new TaskCreation($this->container);
     $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 355691, 'project_id' => 1)));
     $u = new User($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'minicoders')));
     $pp = new ProjectUserRole($this->container);
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
     $g = new GitlabWebhook($this->container);
     $g->setProjectId(1);
     $this->assertNotFalse($g->parsePayload(json_decode(file_get_contents(__DIR__ . '/../fixtures/gitlab_comment_created.json'), true)));
 }
コード例 #11
0
 public function testIssueAssigned()
 {
     $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, array($this, 'onIssueAssigned'));
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'foobar')));
     $tc = new TaskCreation($this->container);
     $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 1, 'project_id' => 1)));
     $u = new User($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'minicoders')));
     $pp = new ProjectUserRole($this->container);
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
     $g = new BitbucketWebhook($this->container);
     $g->setProjectId(1);
     $this->assertNotFalse($g->parsePayload('issue:updated', json_decode(file_get_contents(__DIR__ . '/../fixtures/bitbucket_issue_assigned.json'), true)));
     $this->assertNotEmpty($this->container['dispatcher']->getCalledListeners());
 }
コード例 #12
0
 public function testCloneProjectWithGroups()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pd = new ProjectDuplication($this->container);
     $userModel = new User($this->container);
     $groupModel = new Group($this->container);
     $groupMemberModel = new GroupMember($this->container);
     $projectGroupRoleModel = new ProjectGroupRole($this->container);
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(1, $groupModel->create('G1'));
     $this->assertEquals(2, $groupModel->create('G2'));
     $this->assertEquals(3, $groupModel->create('G3'));
     $this->assertEquals(2, $userModel->create(array('username' => 'user1')));
     $this->assertEquals(3, $userModel->create(array('username' => 'user2')));
     $this->assertEquals(4, $userModel->create(array('username' => 'user3')));
     $this->assertTrue($groupMemberModel->addUser(1, 2));
     $this->assertTrue($groupMemberModel->addUser(2, 3));
     $this->assertTrue($groupMemberModel->addUser(3, 4));
     $this->assertTrue($projectGroupRoleModel->addGroup(1, 1, Role::PROJECT_MANAGER));
     $this->assertTrue($projectGroupRoleModel->addGroup(1, 2, Role::PROJECT_MEMBER));
     $this->assertTrue($projectGroupRoleModel->addGroup(1, 3, Role::PROJECT_VIEWER));
     $this->assertEquals(2, $pd->duplicate(1));
     $this->assertCount(3, $projectGroupRoleModel->getGroups(2));
     $this->assertEquals(Role::PROJECT_MANAGER, $projectUserRoleModel->getUserRole(2, 2));
     $this->assertEquals(Role::PROJECT_MEMBER, $projectUserRoleModel->getUserRole(2, 3));
     $this->assertEquals(Role::PROJECT_VIEWER, $projectUserRoleModel->getUserRole(2, 4));
 }
コード例 #13
0
 public function testAttachEventsWithLoggedUser()
 {
     $this->container['sessionStorage']->user = array('id' => 1);
     $projectModel = new Project($this->container);
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $actionModel = new Action($this->container);
     $actionTaskAssignColorColumn = new TaskAssignColorColumn($this->container);
     $actionManager = new ActionManager($this->container);
     $actionManager->register($actionTaskAssignColorColumn);
     $actions = $actionManager->getAvailableActions();
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
     $this->assertTrue($projectUserRoleModel->addUser(2, 1, Role::PROJECT_MEMBER));
     $this->assertEquals(1, $actionModel->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE, 'action_name' => key($actions), 'params' => array('column_id' => 1, 'color_id' => 'red'))));
     $this->assertEquals(2, $actionModel->create(array('project_id' => 2, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => key($actions), 'params' => array('column_id' => 1, 'color_id' => 'red'))));
     $actionManager->attachEvents();
     $listeners = $this->container['dispatcher']->getListeners(Task::EVENT_MOVE_COLUMN);
     $this->assertCount(1, $listeners);
     $this->assertInstanceOf(get_class($actionTaskAssignColorColumn), $listeners[0][0]);
     $this->assertEquals(2, $listeners[0][0]->getProjectId());
 }
コード例 #14
0
 public function testGetInactiveProjectsByUser()
 {
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $groupModel = new Group($this->container);
     $groupMemberModel = new GroupMember($this->container);
     $groupRoleModel = new ProjectGroupRole($this->container);
     $userRoleModel = new ProjectUserRole($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1', 'is_active' => 0)));
     $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2')));
     $this->assertEquals(2, $userModel->create(array('username' => 'user 1', 'name' => 'User #1')));
     $this->assertEquals(3, $userModel->create(array('username' => 'user 2')));
     $this->assertEquals(4, $userModel->create(array('username' => 'user 3')));
     $this->assertEquals(5, $userModel->create(array('username' => 'user 4')));
     $this->assertEquals(6, $userModel->create(array('username' => 'user 5', 'name' => 'User #5')));
     $this->assertEquals(7, $userModel->create(array('username' => 'user 6')));
     $this->assertEquals(1, $groupModel->create('Group C'));
     $this->assertEquals(2, $groupModel->create('Group B'));
     $this->assertEquals(3, $groupModel->create('Group A'));
     $this->assertTrue($groupMemberModel->addUser(1, 4));
     $this->assertTrue($groupMemberModel->addUser(2, 5));
     $this->assertTrue($groupMemberModel->addUser(3, 3));
     $this->assertTrue($groupMemberModel->addUser(3, 2));
     $this->assertTrue($groupRoleModel->addGroup(1, 1, Role::PROJECT_VIEWER));
     $this->assertTrue($groupRoleModel->addGroup(2, 2, Role::PROJECT_MEMBER));
     $this->assertTrue($groupRoleModel->addGroup(1, 3, Role::PROJECT_MANAGER));
     $this->assertTrue($userRoleModel->addUser(1, 6, Role::PROJECT_MANAGER));
     $this->assertTrue($userRoleModel->addUser(2, 6, Role::PROJECT_MEMBER));
     $this->assertTrue($userRoleModel->addUser(2, 7, Role::PROJECT_MEMBER));
     $projects = $userRoleModel->getProjectsByUser(2, array(Project::INACTIVE));
     $this->assertCount(1, $projects);
     $this->assertEquals('Project 1', $projects[1]);
     $projects = $userRoleModel->getProjectsByUser(3, array(Project::INACTIVE));
     $this->assertCount(1, $projects);
     $this->assertEquals('Project 1', $projects[1]);
     $projects = $userRoleModel->getProjectsByUser(4, array(Project::INACTIVE));
     $this->assertCount(1, $projects);
     $this->assertEquals('Project 1', $projects[1]);
     $projects = $userRoleModel->getProjectsByUser(5, array(Project::INACTIVE));
     $this->assertCount(0, $projects);
     $projects = $userRoleModel->getProjectsByUser(6, array(Project::INACTIVE));
     $this->assertCount(1, $projects);
     $this->assertEquals('Project 1', $projects[1]);
     $projects = $userRoleModel->getProjectsByUser(7, array(Project::INACTIVE));
     $this->assertCount(0, $projects);
 }
コード例 #15
0
 public function testDuplicateWithUserParameterButNotAvailable()
 {
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $actionModel = new Action($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
     $this->assertEquals(2, $userModel->create(array('username' => 'user1')));
     $this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MEMBER));
     $this->assertEquals(1, $actionModel->create(array('project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => '\\Kanboard\\Action\\TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'owner_id' => 2))));
     $this->assertTrue($actionModel->duplicate(1, 2));
     $actions = $actionModel->getAllByProject(2);
     $this->assertCount(0, $actions);
 }
コード例 #16
0
ファイル: UserHelperTest.php プロジェクト: orlov0562/kanboard
 public function testHasProjectAccessForProjectViewers()
 {
     $helper = new User($this->container);
     $user = new UserModel($this->container);
     $project = new Project($this->container);
     $projectUserRole = new ProjectUserRole($this->container);
     $this->container['sessionStorage']->user = array('id' => 2, 'role' => Role::APP_USER);
     $this->assertEquals(1, $project->create(array('name' => 'My project')));
     $this->assertEquals(2, $project->create(array('name' => 'My project')));
     $this->assertEquals(2, $user->create(array('username' => 'user')));
     $this->assertTrue($projectUserRole->addUser(1, 2, Role::PROJECT_VIEWER));
     $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 1));
     $this->assertTrue($helper->hasProjectAccess('board', 'show', 1));
     $this->assertTrue($helper->hasProjectAccess('task', 'show', 1));
     $this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 1));
     $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2));
     $this->assertFalse($helper->hasProjectAccess('board', 'show', 2));
     $this->assertFalse($helper->hasProjectAccess('task', 'show', 2));
     $this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 2));
 }
コード例 #17
0
ファイル: ActionTest.php プロジェクト: phpCedu/kanboard
 public function testDuplicateMixedResults()
 {
     $p = new Project($this->container);
     $pp = new ProjectUserRole($this->container);
     $a = new Action($this->container);
     $u = new User($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(2, $p->create(array('name' => 'P2')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 2)));
     $this->assertEquals(3, $c->create(array('name' => 'C1', 'project_id' => 2)));
     $this->assertEquals(2, $u->create(array('username' => 'unittest1')));
     $this->assertTrue($pp->addUser(1, 2, Role::PROJECT_MEMBER));
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'user_id' => 2))));
     $action = $a->getById(1);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals(2, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignCategoryColor', 'params' => array('color_id' => 'blue', 'category_id' => 1))));
     $action = $a->getById(2);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(1, $action['params'][1]['value']);
     $actions = $a->getAllByProject(1);
     $this->assertNotEmpty($actions);
     $this->assertCount(2, $actions);
     $this->assertTrue($a->duplicate(1, 2));
     $actions = $a->getAllByProject(2);
     $this->assertNotEmpty($actions);
     $this->assertCount(1, $actions);
     $actions = $a->getAll();
     $this->assertNotEmpty($actions);
     $this->assertCount(3, $actions);
     $action = $a->getById($actions[2]['id']);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('color_id', $action['params'][0]['name']);
     $this->assertEquals('blue', $action['params'][0]['value']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(3, $action['params'][1]['value']);
 }