Ejemplo n.º 1
0
 public function testSendWithoutEmailAddress()
 {
     $en = new EmailNotification($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('\\Core\\EmailClient')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
     $this->container['emailClient']->expects($this->never())->method('send');
     $en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
 }
Ejemplo n.º 2
0
 public function testUpdate()
 {
     $u = new User($this->registry);
     $this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
     $this->assertTrue($u->update(array('id' => 2, 'username' => 'biloute')));
     $user = $u->getById(2);
     $this->assertNotFalse($user);
     $this->assertTrue(is_array($user));
     $this->assertEquals('biloute', $user['username']);
     $this->assertEquals('Toto', $user['name']);
     $this->assertEquals(0, $user['is_admin']);
     $this->assertEquals(0, $user['is_ldap_user']);
 }
Ejemplo n.º 3
0
 public function testGetAll()
 {
     $wn = new WebNotification($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)));
     $wn->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
     $wn->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
     $this->assertEmpty($wn->getAll(2));
     $notifications = $wn->getAll(1);
     $this->assertCount(2, $notifications);
     $this->assertArrayHasKey('title', $notifications[0]);
     $this->assertTrue(is_array($notifications[0]['event_data']));
 }
Ejemplo n.º 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']);
 }
Ejemplo n.º 5
0
});
$server->register('removeTask', function ($task_id) use($task) {
    return $task->remove($task_id);
});
$server->register('moveTaskPosition', function ($project_id, $task_id, $column_id, $position) use($task) {
    return $task->movePosition($project_id, $task_id, $column_id, $position);
});
/**
 * User procedures
 */
$server->register('createUser', function (array $values) use($user) {
    list($valid, ) = $user->validateCreation($values);
    return $valid && $user->create($values);
});
$server->register('getUser', function ($user_id) use($user) {
    return $user->getById($user_id);
});
$server->register('getAllUsers', function () use($user) {
    return $user->getAll();
});
$server->register('updateUser', function ($values) use($user) {
    list($valid, ) = $user->validateModification($values);
    return $valid && $user->update($values);
});
$server->register('removeUser', function ($user_id) use($user) {
    return $user->remove($user_id);
});
/**
 * Category procedures
 */
$server->register('createCategory', function ($project_id, $name) use($category) {
Ejemplo n.º 6
0
 public function testFilterUserWithBothFilterAndProjectSelected()
 {
     $u = new User($this->container);
     $n = new Notification($this->container);
     $nf = new NotificationFilter($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' => NotificationFilter::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))));
 }