/**
  * Execute the middleware. Don't call this method directly; it is used by the `Application` internally.
  *
  * @internal
  *
  * @param   ServerRequestInterface $request  The request object
  * @param   ResponseInterface      $response The response object
  * @param   callable               $next     The next middleware handler
  *
  * @return  ResponseInterface
  */
 public function handle(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     $command = $request->getAttribute('command');
     if (empty($command)) {
         throw new \RuntimeException('No command provided');
     }
     $this->commandBus->handle($command);
     $response = $next($request, $response);
     return $response;
 }
Пример #2
0
 /**
  * @testdox The command bus has a handle method that takes a Query as a parameter
  */
 public function testTheCommandBusHasAnExecuteMethodThatTakesAQueryAsAParameter()
 {
     $this->assertEquals('XSome contentY', $this->commandBus->handle(new SimpleQuery('Some content')));
 }
 /**
  * @testdox The modified command bus has an execute method that takes a Query as a parameter
  */
 public function testTheCommandBusHasAnExecuteMethodThatTakesAQueryAsAParameter()
 {
     $this->expectOutputString(sprintf("LOG: Starting %1\$s\nLOG: Ending %1\$s\n", "Joomla\\Tests\\Unit\\Service\\Stubs\\SimpleQuery"));
     $this->assertEquals('XSome contentY', $this->commandBus->handle(new SimpleQuery('Some content')));
 }