Пример #1
0
 public function testSendWithoutEmailAddress()
 {
     $en = new Mail($this->container);
     $p = new Project($this->container);
     $tf = new TaskFinder($this->container);
     $tc = new TaskCreation($this->container);
     $u = new User($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->container['emailClient'] = $this->getMockBuilder('\\Kanboard\\Core\\Mail\\Client')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
     $this->container['emailClient']->expects($this->never())->method('send');
     $en->notifyUser($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
 }
 public function testNotifyUserWithWebhookNotConfigured()
 {
     $this->container['userMetadata']->save(1, array('rocketchat_webhook_url' => ''));
     $this->container['httpClient']->expects($this->never())->method('postForm');
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $taskFinderModel = new TaskFinder($this->container);
     $handler = new RocketChat($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $user = $userModel->getById(1);
     $task = $taskFinderModel->getDetails(1);
     $event = array('task' => $task);
     $event['task']['task_id'] = $task['id'];
     $handler->notifyUser($user, Task::EVENT_MOVE_COLUMN, $event);
 }
Пример #3
0
 public function testEnableDisable()
 {
     $userModel = new User($this->container);
     $this->assertEquals(2, $userModel->create(array('username' => 'toto')));
     $this->assertTrue($userModel->isActive(2));
     $user = $userModel->getById(2);
     $this->assertEquals(1, $user['is_active']);
     $this->assertTrue($userModel->disable(2));
     $user = $userModel->getById(2);
     $this->assertEquals(0, $user['is_active']);
     $this->assertFalse($userModel->isActive(2));
     $this->assertTrue($userModel->enable(2));
     $user = $userModel->getById(2);
     $this->assertEquals(1, $user['is_active']);
     $this->assertTrue($userModel->isActive(2));
 }
Пример #4
0
 public function testEnableDisablePublicAccess()
 {
     $u = new User($this->container);
     $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456')));
     $user = $u->getById(2);
     $this->assertNotEmpty($user);
     $this->assertEquals('toto', $user['username']);
     $this->assertEmpty($user['token']);
     $this->assertTrue($u->enablePublicAccess(2));
     $user = $u->getById(2);
     $this->assertNotEmpty($user);
     $this->assertEquals('toto', $user['username']);
     $this->assertNotEmpty($user['token']);
     $this->assertTrue($u->disablePublicAccess(2));
     $user = $u->getById(2);
     $this->assertNotEmpty($user);
     $this->assertEquals('toto', $user['username']);
     $this->assertEmpty($user['token']);
 }
 public function testFilterUserWithBothFilterAndProjectSelected()
 {
     $u = new User($this->container);
     $n = new UserNotification($this->container);
     $nf = new UserNotificationFilter($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH)));
     $n->saveSettings(2, array('notifications_enabled' => 1, 'notification_projects' => array(2 => true)));
     $this->assertFalse($nf->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 2, 'owner_id' => 3))));
     $this->assertFalse($nf->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 0, 'owner_id' => 2))));
     $this->assertTrue($nf->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 2, 'creator_id' => 2, 'owner_id' => 3))));
     $this->assertTrue($nf->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 2, 'creator_id' => 0, 'owner_id' => 2))));
 }
 /**
  * Send overdue tasks to project admin
  *
  * @access public
  * @param  array   $overdue_tasks
  * @param  array   $projects
  * @param  array   $project_managers
  */
 public function sendOverdueTaskNotificationsToAdmin(array $overdue_tasks, array $projects, array $project_managers)
 {
     foreach ($project_managers as $project_id => $managers) {
         foreach ($managers as $manager_id => $manager) {
             $user = User::getById($manager_id);
             $this->userNotification->sendUserNotification($user, Task::EVENT_OVERDUE, array('tasks' => $overdue_tasks[$project_id], 'project_name' => $projects[$project_id]));
         }
     }
 }