Exemplo n.º 1
0
 /**
  * If appropriate, validate command data.
  *
  * @param $command
  */
 protected function validateCommand($command)
 {
     $validator = $this->commandTranslator->toValidator($command);
     if (class_exists($validator)) {
         $this->app->make($validator)->validate($command);
     }
 }
 function it_handles_command_if_validation_succeeds(Application $application, CommandTranslator $translator, CommandBus $bus, ExampleCommand $command, ExampleValidator $validator)
 {
     // Own responsibility
     $translator->toValidator($command)->willReturn(ExampleValidator::class);
     $application->make(ExampleValidator::class)->willReturn($validator);
     // Delegated responsibility
     $bus->execute($command)->shouldBeCalled();
     $this->execute($command);
 }