public function testDeliver()
 {
     $notification = new TicketNotification('unique_id', 1, 'Header', 'Subject', new \ArrayIterator(array('key' => 'value')), array('file.ext'));
     $manager = new NotificationDeliveryManager();
     $manager->add($notification);
     $this->notifier->expects($this->once())->method('notify')->with($notification);
     $manager->deliver($this->notifier);
 }
 public function testProcessEvent()
 {
     $user = new User();
     $user->setId(1);
     $this->configManager->expects($this->once())->method('get')->with('diamante_desk.email_notification')->will($this->returnValue(true));
     $this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
     $event = $this->event();
     $this->notificationDeliveryManager->expects($this->once())->method('add')->with($this->logicalAnd($this->isInstanceOf('\\Diamante\\DeskBundle\\Model\\Ticket\\Notifications\\TicketNotification'), $this->attributeEqualTo('ticketUniqueId', $event->getAggregateId()), $this->attributeEqualTo('author', $user), $this->attributeEqualTo('headerText', $event->getHeaderText()), $this->attributeEqualTo('subject', $event->getSubject()), $this->attributeEqualTo('attachments', $event->attachments()), $this->attribute($this->logicalAnd($this->isInstanceOf('\\ArrayIterator'), $this->arrayHasKey('Description'), $this->contains('New Description')), 'changeList')));
     $this->subscriber->processEvent($event);
 }
 /**
  * @param Ticket $ticket
  */
 private function dispatchEvents(Ticket $ticket)
 {
     foreach ($ticket->getRecordedEvents() as $event) {
         $this->dispatcher->dispatch($event->getEventName(), $event);
     }
     $this->notificationDeliveryManager->deliver($this->notifier);
 }
 /**
  * @param NotificationEvent $event
  * @return void
  */
 public function processEvent(NotificationEvent $event)
 {
     if (false === $this->isNotificationsEnabled()) {
         return;
     }
     if ($event instanceof CommentsEvent && $event->isPrivate() && !$this->userState->isOroUser()) {
         return;
     }
     $changeList = new \ArrayIterator();
     if ($event instanceof ChangesProviderEvent) {
         $event->provideChanges($changeList);
     }
     $attachments = array();
     if ($event instanceof AttachmentsEvent) {
         $attachments = $event->attachments();
     }
     $user = $this->securityFacade->getLoggedUser();
     $notification = new TicketNotification($event->getAggregateId(), $user, $event->getHeaderText(), $event->getSubject(), $changeList, $attachments);
     $this->manager->add($notification);
 }
 /**
  * Dispatches events
  *
  * @param Ticket $ticket
  */
 private function dispatchEvents(Ticket $ticket)
 {
     $events = $ticket->getRecordedEvents();
     if (empty($events)) {
         return;
     }
     foreach ($events as $event) {
         $this->dispatcher->dispatch($event->getEventName(), $event);
     }
     $this->notificationDeliveryManager->deliver($this->notifier);
 }