function it_executes_a_command(Command $cmd, Container $container, NameInflector $inflector, FooHandler $handler) { $inflector->getHandler(get_class($cmd->getWrappedObject()))->willReturn('FooHandler')->shouldBeCalled(); $container->resolve('FooHandler')->willReturn($handler)->shouldBeCalled(); $handler->handle($cmd)->shouldBeCalled(); $this->execute($cmd); }
private function resolveHandlerClass($commandClass) { return isset($this->handlers[$commandClass]) ? $this->handlers[$commandClass] : $this->inflector->getHandler($commandClass); }