コード例 #1
0
 public function testHandlePayload()
 {
     $w = new MailgunWebhook($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(2, $u->create(array('name' => '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->parsePayload(array()));
     // Unknown user
     $this->assertFalse($w->parsePayload(array('sender' => 'a@b.c', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo')));
     // Project not found
     $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo')));
     // User is not member
     $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
     $this->assertTrue($pp->addMember(2, 2));
     // The task must be created
     $this->assertTrue($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
     $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 testHtml2Markdown()
 {
     $w = new Postmark($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($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' => 'test2', 'identifier' => 'TEST1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => 'boo', 'HtmlBody' => '<p><strong>boo</strong></p>')));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**boo**', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     $this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => '**boo**', 'HtmlBody' => '')));
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**boo**', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
 }
コード例 #3
0
ファイル: SendgridTest.php プロジェクト: redarrow/kanboard
 public function testHandlePayload()
 {
     $w = new Sendgrid($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($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('envelope' => '{"to":["a@b.c"],"from":"a.b.c"}', 'subject' => 'Email task')));
     // Project not found
     $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["a@b.c"],"from":"me@localhost"}', 'subject' => 'Email task')));
     // User is not member
     $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task')));
     $this->assertTrue($pp->addMember(2, 2));
     // The task must be created
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task')));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     // Html content
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> text')));
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**bold** text', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     // Text content
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'text' => '**bold** text')));
     $task = $tf->getById(3);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**bold** text', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     // Text + html content
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> html', 'text' => '**bold** text')));
     $task = $tf->getById(4);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**bold** html', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
 }
コード例 #4
0
 public function testClonePrivateProject()
 {
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'Private', 'is_private' => 1), 1, true));
     $this->assertEquals(2, $p->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('Private (Clone)', $project['name']);
     $this->assertEquals(1, $project['is_private']);
     $this->assertEquals(0, $project['is_public']);
     $this->assertEmpty($project['token']);
     $pp = new ProjectPermission($this->container);
     $this->assertEquals(array(1 => 'admin'), $pp->getMembers(1));
     $this->assertEquals(array(1 => 'admin'), $pp->getMembers(2));
 }
コード例 #5
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 ProjectPermission($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->addMember(1, 2));
     $this->assertTrue($pp->addMember(2, 2));
     $this->assertTrue($pp->isUserAllowed(1, 2));
     $this->assertTrue($pp->isUserAllowed(2, 2));
     // 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(5, $task['column_id']);
 }
コード例 #6
0
 public function testCloneProjectWithUsers()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectPermission($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->addMember(1, 2));
     $this->assertTrue($pp->addMember(1, 4));
     $this->assertTrue($pp->addManager(1, 3));
     $this->assertTrue($pp->isMember(1, 2));
     $this->assertTrue($pp->isMember(1, 3));
     $this->assertTrue($pp->isMember(1, 4));
     $this->assertFalse($pp->isManager(1, 2));
     $this->assertTrue($pp->isManager(1, 3));
     $this->assertFalse($pp->isManager(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->getMembers(2)));
     $this->assertTrue($pp->isMember(2, 2));
     $this->assertTrue($pp->isMember(2, 3));
     $this->assertTrue($pp->isMember(2, 4));
     $this->assertFalse($pp->isManager(2, 2));
     $this->assertTrue($pp->isManager(2, 3));
     $this->assertFalse($pp->isManager(2, 4));
 }
コード例 #7
0
ファイル: AclTest.php プロジェクト: jewelhuqsapp/kanboard
 public function testPageAccessNotMember()
 {
     $acl = new Acl($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     // We create our user
     $this->assertEquals(2, $u->create(array('username' => 'unittest', 'password' => 'unittest')));
     // We create a project and set our user as member
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $this->assertFalse($pp->isMember(1, 2));
     $this->assertFalse($pp->isManager(1, 2));
     $session = new Session();
     $session['user'] = array('id' => 2, 'is_admin' => false);
     $this->assertFalse($acl->isAllowed('board', 'show', 2));
     $this->assertFalse($acl->isAllowed('board', 'show', 1));
     $this->assertFalse($acl->isAllowed('task', 'show', 1));
     $this->assertFalse($acl->isAllowed('task', 'update', 1));
     $this->assertFalse($acl->isAllowed('project', 'show', 1));
     $this->assertFalse($acl->isAllowed('config', 'application', 1));
     $this->assertFalse($acl->isAllowed('project', 'users', 1));
     $this->assertFalse($acl->isAllowed('task', 'remove', 1));
     $this->assertTrue($acl->isAllowed('app', 'index', 1));
 }
コード例 #8
0
ファイル: ActionTest.php プロジェクト: redarrow/kanboard
 public function testDuplicateMixedResults()
 {
     $p = new Project($this->container);
     $pp = new ProjectPermission($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->addMember(1, 2));
     $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']);
 }
コード例 #9
0
 public function testCommentCreatedWithUser()
 {
     $this->container['dispatcher']->addListener(GithubWebhook::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' => 3, 'project_id' => 1)));
     $u = new User($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'fguillot')));
     $pp = new ProjectPermission($this->container);
     $this->assertTrue($pp->addMember(1, 2));
     $g = new GithubWebhook($this->container);
     $g->setProjectId(1);
     $this->assertNotFalse($g->parsePayload('issue_comment', json_decode(file_get_contents(__DIR__ . '/../fixtures/github_comment_created.json'), true)));
 }
コード例 #10
0
 public function testGetUserList()
 {
     $u = new User($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $n = new Notification($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $this->assertEquals(3, $p->create(array('name' => 'UnitTest3', 'is_everybody_allowed' => 1)));
     // 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')));
     // We allow all users to be member of our projects
     $this->assertTrue($pp->allowUser(1, 1));
     $this->assertTrue($pp->allowUser(1, 2));
     $this->assertTrue($pp->allowUser(1, 3));
     $this->assertTrue($pp->allowUser(1, 4));
     $this->assertTrue($pp->allowUser(2, 1));
     $this->assertTrue($pp->allowUser(2, 2));
     $this->assertTrue($pp->allowUser(2, 3));
     $this->assertTrue($pp->allowUser(2, 4));
     $users = $n->getUsersList(1);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
     $users = $n->getUsersList(2);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
     // User 3 choose to receive notification only for project 2
     $n->saveSettings(4, array('notifications_enabled' => 1, 'projects' => array(2 => true)));
     $users = $n->getUsersList(1);
     $this->assertNotEmpty($users);
     $this->assertEquals(1, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $users = $n->getUsersList(2);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
     // User 1 excluded
     $users = $n->getUsersList(1, array(2));
     $this->assertEmpty($users);
     $users = $n->getUsersList(2, array(2));
     $this->assertNotEmpty($users);
     $this->assertEquals(1, count($users));
     $this->assertEquals('user3@here', $users[0]['email']);
     // Project #3 allow everybody
     $users = $n->getUsersList(3);
     $this->assertNotEmpty($users);
     $this->assertEquals(1, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $users = $n->getUsersWithNotification(3);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
 }
コード例 #11
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../app/common.php';
use Model\Project;
use Model\ProjectPermission;
$projectModel = new Project($container);
$permissionModel = new ProjectPermission($container);
for ($i = 0; $i < 100; $i++) {
    $id = $projectModel->create(array('name' => 'Project #' . $i));
    $permissionModel->addMember($id, 1);
}
コード例 #12
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../app/common.php';
use Model\TaskCreation;
use Model\SubTask;
use Model\Project;
use Model\ProjectPermission;
use Model\User;
$task_per_column = 200;
$userModel = new User($container);
$projectModel = new Project($container);
$permissionModel = new ProjectPermission($container);
$taskModel = new TaskCreation($container);
$subtaskModel = new SubTask($container);
$project_id = $projectModel->create(array('name' => 'Project #1'));
$permissionModel->addMember($project_id, 1);
for ($i = 0; $i <= 5; $i++) {
    $userModel->create(array('username' => 'user' . $i, 'password' => 'password' . $i, 'name' => 'User #' . $i, 'email' => 'user' . $i . '@localhost'));
}
foreach (array(1, 2, 3, 4) as $column_id) {
    for ($i = 1; $i <= $task_per_column; $i++) {
        $task = array('title' => 'Task #' . $i . '-' . $column_id, 'project_id' => 1, 'column_id' => $column_id, 'owner_id' => 1, 'color_id' => mt_rand(0, 1) === 0 ? 'green' : 'purple', 'score' => mt_rand(0, 21), 'is_active' => mt_rand(0, 1));
        $id = $taskModel->create($task);
        $subtaskModel->create(array('title' => 'Subtask of task #' . $id, 'user_id' => 1, 'status' => mt_rand(0, 2), 'task_id' => $id));
    }
}
コード例 #13
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 ProjectPermission($this->container);
     $this->assertTrue($pp->addMember(1, 2));
     $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());
 }
コード例 #14
0
ファイル: UserHelperTest.php プロジェクト: redarrow/kanboard
 public function testIsProjectManagementAllowedForProjectManager()
 {
     $h = new User($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new UserModel($this->container);
     $session = new Session();
     // We create our user
     $this->assertEquals(2, $u->create(array('username' => 'unittest', 'password' => 'unittest')));
     // We create a project and set our user as project member
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     $this->assertTrue($pp->addManager(1, 2));
     $this->assertTrue($pp->isMember(1, 2));
     $this->assertTrue($pp->isManager(1, 2));
     // We fake a session for him
     $session['user'] = array('id' => 2, 'is_admin' => false, 'is_project_admin' => false);
     $this->assertTrue($h->isProjectManagementAllowed(1));
 }
コード例 #15
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../app/common.php';
use Model\TaskCreation;
use Model\SubTask;
use Model\Project;
use Model\ProjectPermission;
use Model\User;
$task_per_column = 50;
$userModel = new User($container);
$projectModel = new Project($container);
$permissionModel = new ProjectPermission($container);
$taskModel = new TaskCreation($container);
$subtaskModel = new SubTask($container);
for ($i = 0; $i <= 100; $i++) {
    $id = $projectModel->create(array('name' => 'Project #' . $i));
    $permissionModel->allowUser($id, 1);
}
for ($i = 0; $i <= 500; $i++) {
    $userModel->create(array('username' => 'user' . $i, 'password' => 'password' . $i, 'name' => 'User #' . $i, 'email' => 'user' . $i . '@localhost'));
}
foreach (array(1, 2, 3, 4) as $column_id) {
    for ($i = 1; $i <= $task_per_column; $i++) {
        $task = array('title' => 'Task #' . $i . '-' . $column_id, 'project_id' => mt_rand(1, 100), 'column_id' => $column_id, 'owner_id' => 1, 'color_id' => mt_rand(0, 1) === 0 ? 'green' : 'purple', 'score' => mt_rand(0, 21), 'is_active' => mt_rand(0, 1));
        $id = $taskModel->create($task);
        $subtaskModel->create(array('title' => 'Subtask of task #' . $id, 'user_id' => 1, 'status' => mt_rand(0, 2), 'task_id' => $id));
    }
}
コード例 #16
0
 public function testSendNotificationsToAnotherAssignee()
 {
     $u = new User($this->container);
     $p = new Project($this->container);
     $n = new Notification($this->container);
     $pp = new ProjectPermission($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertEquals(2, $u->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1)));
     $this->assertTrue($pp->addMember(1, 2));
     $this->container['emailClient']->expects($this->never())->method('send');
     $n->sendNotifications('task.open', array('task' => array('id' => 2, 'title' => 'blah', 'project_name' => 'test', 'project_id' => 1, 'owner_id' => 1, 'creator_id' => 1)));
 }
コード例 #17
0
 public function testUsersList()
 {
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $user = new User($this->container);
     $this->assertNotFalse($user->create(array('username' => 'unittest', 'password' => 'unittest')));
     // We create project
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     // No restriction, we should have no body
     $this->assertEquals(array('Unassigned'), $pp->getMemberList(1));
     // We allow only the regular user
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertEquals(array(0 => 'Unassigned', 2 => 'unittest'), $pp->getMemberList(1));
     // We allow the admin user
     $this->assertTrue($pp->addMember(1, 1));
     $this->assertEquals(array(0 => 'Unassigned', 1 => 'admin', 2 => 'unittest'), $pp->getMemberList(1));
     // We revoke only the regular user
     $this->assertTrue($pp->revokeMember(1, 2));
     $this->assertEquals(array(0 => 'Unassigned', 1 => 'admin'), $pp->getMemberList(1));
     // We revoke only the admin user, we should have everybody
     $this->assertTrue($pp->revokeMember(1, 1));
     $this->assertEquals(array(0 => 'Unassigned'), $pp->getMemberList(1));
 }
コード例 #18
0
ファイル: NotificationTest.php プロジェクト: hj3938/kanboard
 public function testSendNotifications()
 {
     $u = new User($this->container);
     $n = new Notification($this->container);
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $pp = new ProjectPermission($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1)));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertTrue($u->update(array('id' => 1, 'email' => 'test@localhost')));
     $this->assertTrue($pp->isEverybodyAllowed(1));
     $n->saveSettings(1, array('notifications_enabled' => 1, 'notifications_filter' => NotificationFilter::FILTER_NONE, 'notification_types' => array(NotificationType::TYPE_WEB => 1, NotificationType::TYPE_EMAIL => 1)));
     $this->container['emailNotification'] = $this->getMockBuilder('\\Model\\EmailNotification')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
     $this->container['webNotification'] = $this->getMockBuilder('\\Model\\WebNotification')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
     $this->container['emailNotification']->expects($this->once())->method('send');
     $this->container['webNotification']->expects($this->once())->method('send');
     $n->sendNotifications(Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
 }