Exemplo n.º 1
0
 public function testAllowEverybody()
 {
     $user = new User($this->container);
     $this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
     $this->assertNotFalse($user->create(array('username' => 'unittest#2', 'password' => 'unittest')));
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     $this->assertFalse($pp->isEverybodyAllowed(1));
     $this->assertTrue($pp->isUserAllowed(1, 1));
     $this->assertFalse($pp->isUserAllowed(1, 2));
     $this->assertFalse($pp->isUserAllowed(1, 3));
     $this->assertEquals(array(), $pp->getMembers(1));
     $this->assertEquals(array('Unassigned'), $pp->getMemberList(1));
     $this->assertEmpty($pp->getMemberProjects(1));
     $this->assertEmpty($pp->getMemberProjects(2));
     $this->assertEmpty($pp->getMemberProjects(3));
     $this->assertEmpty($pp->getMemberProjectIds(1));
     $this->assertEmpty($pp->getMemberProjectIds(2));
     $this->assertEmpty($pp->getMemberProjectIds(3));
     $this->assertEmpty($pp->getActiveMemberProjectIds(1));
     $this->assertEmpty($pp->getActiveMemberProjectIds(2));
     $this->assertEmpty($pp->getActiveMemberProjectIds(3));
     $this->assertEmpty($pp->getActiveMemberProjects(1));
     $this->assertEmpty($pp->getActiveMemberProjects(2));
     $this->assertEmpty($pp->getActiveMemberProjects(3));
     $this->assertTrue($p->update(array('id' => 1, 'is_everybody_allowed' => 1)));
     $this->assertTrue($pp->isEverybodyAllowed(1));
     $this->assertTrue($pp->isUserAllowed(1, 1));
     $this->assertTrue($pp->isUserAllowed(1, 2));
     $this->assertTrue($pp->isUserAllowed(1, 3));
     $this->assertEquals(array('1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getMembers(1));
     $this->assertEquals(array('Unassigned', '1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getMemberList(1));
     $this->assertNotEmpty($pp->getMemberProjects(1));
     $this->assertNotEmpty($pp->getMemberProjects(2));
     $this->assertNotEmpty($pp->getMemberProjects(3));
     $this->assertNotEmpty($pp->getMemberProjectIds(1));
     $this->assertNotEmpty($pp->getMemberProjectIds(2));
     $this->assertNotEmpty($pp->getMemberProjectIds(3));
     $this->assertNotEmpty($pp->getActiveMemberProjectIds(1));
     $this->assertNotEmpty($pp->getActiveMemberProjectIds(2));
     $this->assertNotEmpty($pp->getActiveMemberProjectIds(3));
     $this->assertNotEmpty($pp->getActiveMemberProjects(1));
     $this->assertNotEmpty($pp->getActiveMemberProjects(2));
     $this->assertNotEmpty($pp->getActiveMemberProjects(3));
     $this->assertTrue($p->disable(1));
     $this->assertEmpty($pp->getActiveMemberProjectIds(1));
     $this->assertEmpty($pp->getActiveMemberProjectIds(2));
     $this->assertEmpty($pp->getActiveMemberProjectIds(3));
     $this->assertEmpty($pp->getActiveMemberProjects(1));
     $this->assertEmpty($pp->getActiveMemberProjects(2));
     $this->assertEmpty($pp->getActiveMemberProjects(3));
 }
Exemplo n.º 2
0
 public function testGetUsersWithNotificationsWhenEverybodyAllowed()
 {
     $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', 'is_everybody_allowed' => 1)));
     $this->assertTrue($pp->isEverybodyAllowed(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')));
     $users = $n->getUsersWithNotificationEnabled(1);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
 }
Exemplo n.º 3
0
 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)));
 }