Пример #1
0
 /**
  * Registers a command handler
  *
  * @param string         $commandClass The full command class name
  * @param CommandHandler $handler      The command handler
  *
  * @return void
  *
  * @throws InvalidCommandException When the command class is not valid
  */
 public function registerHandler($commandClass, CommandHandler $handler)
 {
     if (!Test::implementsInterface($commandClass, Command::class)) {
         $message = sprintf('Invalid command class: %s', $commandClass);
         throw InvalidCommandException::create($message);
     }
     $type = Type::create($commandClass)->toString();
     $this->handlers[$type] = $handler;
 }
 public function test_that_create_returns_exception_instance()
 {
     $exception = InvalidCommandException::create('Invalid command');
     $this->assertInstanceOf('Novuso\\Common\\Application\\Messaging\\Command\\Exception\\InvalidCommandException', $exception);
 }