Esempio n. 1
0
 /**
  * Builds URI for provided route instance.
  *
  * @param RouteContract $route
  * @param array $variables
  * @param array $query
  * @return UriInterface
  */
 private function buildRouteUri(RouteContract $route, array $variables = [], array $query = []) : UriInterface
 {
     $uri = $this->uri->withScheme($route->getScheme() ?: $this->request->getUri()->getScheme())->withHost($route->getHost() ?: $this->request->getUri()->getHost())->withPath($route->compilePath($variables));
     if ($query) {
         $uri = $uri->withQuery(http_build_query($query));
     }
     return $uri;
 }
Esempio n. 2
0
 function it_generates_url_to_current_route(Request $request, Route $route, UriInterface $uri)
 {
     $request->getRoute()->willReturn($route);
     $route->getScheme()->willReturn('http');
     $route->getHost()->willReturn('example.com');
     $route->compilePath(['key' => 'value'])->willReturn('/url');
     $uri->withScheme('http')->willReturn($uri);
     $uri->withHost('example.com')->willReturn($uri);
     $uri->withPath('/url')->willReturn($uri);
     $uri->withQuery('param=val')->willReturn($uri);
     $result = $this->toCurrent(['key' => 'value'], ['param' => 'val']);
     $result->shouldBe($uri);
     $uri->withScheme('http')->shouldHaveBeenCalled();
     $uri->withHost('example.com')->shouldHaveBeenCalled();
     $uri->withPath('/url')->shouldHaveBeenCalled();
 }
Esempio n. 3
0
 function let(Request $request)
 {
     $request->getQueryParams()->willReturn(['query' => 'value']);
     $request->getParsedBody()->willReturn(['body' => 'value']);
     $request->getUploadedFiles()->willReturn(['files' => 'value']);
     $request->getCookieParams()->willReturn(['cookie' => 'value']);
     $request->getAttributes()->willReturn(['attribute' => 'value']);
 }
Esempio n. 4
0
 /**
  * @inheritDoc
  */
 public function process(Request $request) : array
 {
     return [array_replace((array) $request->getQueryParams(), (array) $request->getParsedBody(), (array) $request->getUploadedFiles(), (array) $request->getCookieParams(), (array) $request->getAttributes())];
 }