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); }
/** * @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); }