Exemplo n.º 1
0
 public function testSendNotifications()
 {
     $u = new User($this->container);
     $n = new UserNotification($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' => UserNotificationFilter::FILTER_NONE, 'notification_types' => array('web' => 1, 'email' => 1)));
     $notifier = $this->getMockBuilder('Stdclass')->setMethods(array('notifyUser'))->getMock();
     $notifier->expects($this->exactly(2))->method('notifyUser');
     $this->container['userNotificationType']->expects($this->at(0))->method('getSelectedTypes')->will($this->returnValue(array('email', 'web')));
     $this->container['userNotificationType']->expects($this->at(1))->method('getType')->with($this->equalTo('email'))->will($this->returnValue($notifier));
     $this->container['userNotificationType']->expects($this->at(2))->method('getType')->with($this->equalTo('web'))->will($this->returnValue($notifier));
     $n->sendNotifications(Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
 }