public function test_that_it_can_resolve_the_command_handler() { $handler = $this->container->get('command.handler.create_task'); $commandMap = new CommandMemoryMap(); $commandMap->registerHandlers([CreateTaskCommand::class => $handler]); $resolver = new CommandMemoryResolver($commandMap); $command = new CreateTaskCommand('test'); $this->assertSame($handler, $resolver->resolve($command)); }
/** * {@inheritdoc} */ public function resolve(Command $command) { return $this->handlerMap->getHandler(get_class($command)); }
/** * @expectedException Novuso\Common\Application\Messaging\Command\Exception\InvalidCommandException */ public function test_that_register_handler_throws_exception_for_invalid_command_class() { $handler = $this->container->get('command.handler.create_task'); $commandMap = new CommandMemoryMap(); $commandMap->registerHandlers(['FooBarBaz' => $handler]); }