コード例 #1
0
 /**
  * If appropriate, validate query data.
  *
  * @param $query
  */
 protected function validateQuery($query)
 {
     $validator = $this->queryTranslator->toValidator($query);
     if (class_exists($validator)) {
         $this->app->make($validator)->validate($query);
     }
 }
コード例 #2
0
 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);
 }