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