/** * @test * @expectedException \HelloFresh\Engine\CommandBus\Exception\CanNotInvokeHandlerException */ public function itFailsWhenHandlerHasAnInvalidHandleMethod() { $handler = new InvalidHandler(); $this->locator->addHandler(TestCommand::class, $handler); $command = new TestCommand("hey"); $this->commandBus->execute($command); }
/** * {@inheritDoc} */ public function execute($command) { try { $this->commandBus->execute($command); $this->dispatcher->dispatch(self::EVENT_COMMAND_SUCCESS, ['command' => $command]); } catch (\Exception $e) { $this->dispatcher->dispatch(self::EVENT_COMMAND_FAILURE, ['command' => $command, 'exception' => $e]); throw $e; } }