function it_handles_command_if_validation_succeeds(Application $application, QueryTranslator $translator, QueryBus $bus, ExampleQuery $query, ExampleValidator $validator)
 {
     // Own responsibility
     $translator->toValidator($query)->willReturn(ExampleValidator::class);
     $application->make(ExampleValidator::class)->willReturn($validator);
     // Delegated responsibility
     $bus->executeQuery($query)->shouldBeCalled();
     $this->executeQuery($query);
 }
 /**
  * Execute a query with validation.
  *
  * @param $query
  *
  * @return mixed
  */
 public function executeQuery($query)
 {
     // If a validator is "registered," we will
     // first trigger it, before moving forward.
     $this->validateQuery($query);
     // Next, we'll execute any registered decorators.
     $this->executeDecorators($query);
     // And finally pass through to the handler class.
     return $this->bus->executeQuery($query);
 }