Example #1
0
 /**
  * Test addMiddlewareAfter method.
  */
 public function testAddMiddlewareAfter()
 {
     $this->given($middleware = new LockingMiddleware())->and($bus = new Bus([12 => $middleware]))->when($result = $bus->addMiddlewareAfter($middleware, $middleware))->then()->variable($result)->isNull();
     $this->given($middleware = new LockingMiddleware())->and($bus = new Bus())->then()->exception(function () use($bus, $middleware) {
         $bus->addMiddlewareAfter($middleware, $middleware);
     })->isInstanceOf(\InvalidArgumentException::class);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function dispatch(MessageInterface $event)
 {
     if (!$event instanceof EventInterface) {
         throw new \InvalidArgumentException(sprintf('The object must be an instance of %s. Instance of %s given', EventInterface::class, get_class($event)));
     }
     $this->ensureEventDispatcherMiddleware();
     parent::dispatch($event);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function dispatch(MessageInterface $query)
 {
     if (!$query instanceof QueryInterface) {
         throw new \InvalidArgumentException(sprintf('The object must be an instance of %s. Instance of %s given', QueryInterface::class, get_class($query)));
     }
     $this->ensureQueryHandlerMiddleware();
     return parent::dispatch($query);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function dispatch(MessageInterface $command)
 {
     if (!$command instanceof CommandInterface) {
         throw new \InvalidArgumentException(sprintf('The object must be an instance of %s. Instance of %s given', CommandInterface::class, get_class($command)));
     }
     $this->ensureCommandHandlerMiddleware();
     parent::dispatch($command);
 }