示例#1
0
 public function testValidationThroughWhenNotMatchedRouting()
 {
     $request = ServerRequestFactory::fromGlobals(['REQUEST_METHOD' => 'GET'])->withUri(new Uri('/entry'));
     $response = new Response();
     $dispatcher = new Dispatcher(call_user_func(function () {
         $error = (yield function (ServerRequestInterface $request) {
             return $request->getMethod() === 'POST' && $request->getUri()->getPath() === '/entry';
         } => function () {
             return new ValidationError(['foo']);
         });
         (yield '/entry' => function () use($error) {
             return 'error is ' . gettype($error);
         });
     }), $this->view, $this->router);
     $result = $dispatcher->dispatch($request, $response);
     $response = $dispatcher->getActionResponse();
     $this->assertSame('error is NULL', (string) $response->getBody());
 }