Exemplo n.º 1
0
 public function testShouldSkipNotSupportedHandlers()
 {
     $notification = Email::create();
     $handler = $this->prophesize(NotificationHandlerInterface::class);
     $handler->getName()->willReturn('swiftmailer');
     $handler->supports(Argument::any())->willReturn(false);
     $handler->notify(Argument::any())->shouldNotBeCalled();
     $handler2 = $this->prophesize(NotificationHandlerInterface::class);
     $handler2->getName()->willReturn('default');
     $handler2->supports(Argument::any())->willReturn(true);
     $handler2->notify(Argument::any())->shouldBeCalled();
     $this->manager->addHandler($handler->reveal());
     $this->manager->addHandler($handler2->reveal());
     $this->manager->notify($notification);
 }
Exemplo n.º 2
0
 /**
  * Initializes {@see Notifire} class with the current {@see NotificationInterface}
  * and instance of {@see EventDispatcherInterface}
  *
  * @throws Exception\NotificationAlreadyRegisteredException
  * @throws Exception\UnsupportedClassException
  */
 public function initialize()
 {
     Notifire::reset();
     $manager = new NotificationManager();
     $manager->setThrowIfNotNotified(true);
     foreach ($this->handlers as $handler) {
         $manager->addHandler($handler);
     }
     if (null === $this->dispatcher) {
         $this->dispatcher = new EventDispatcher();
     }
     $manager->setEventDispatcher($this->dispatcher);
     foreach ($this->notifications as $notificationName => $notificationClass) {
         Notifire::addNotification($notificationName, $notificationClass);
     }
     Notifire::setManager($manager);
 }