コード例 #1
0
 protected function getRequest()
 {
     $request = new Request();
     $request->setUri('http://localhost/base-path/asset-path');
     $request->setBasePath('/base-path');
     return $request;
 }
コード例 #2
0
 public function testDetect()
 {
     $request = new Request();
     $request->setUri('http://test.de');
     $event = new LocaleEvent();
     $event->setRequest($request);
     $event->setSupported(array('en_GB', 'de_DE'));
     $strategy = new HostStrategy();
     $strategy->setOptions(array('domain' => 'test.:locale', 'aliases' => array('de' => 'de_DE', 'co.uk' => 'en_GB')));
     $result = $strategy->detect($event);
     $this->assertSame('de_DE', $result);
 }
コード例 #3
0
ファイル: Url.php プロジェクト: Andyyang1981/pi
 /**
  * Match a URL against routes and parse to parameters
  *
  * Note: host is not checked for match
  *
  * @param string $url
  * @param string $route
  *
  * @throws \RuntimeException
  * @return RouteMatch|null
  */
 public function match($url, $route = '')
 {
     if (!$this->getRouter()) {
         throw new \RuntimeException('No RouteStackInterface instance provided');
     }
     $uri = new HttpUri($url);
     $request = new Request();
     $request->setUri($uri);
     $result = $this->getRouter()->match($request, $route);
     return $result;
 }
コード例 #4
0
 public function testFoundDoesNotRedirectWhenLocaleIsInPath()
 {
     $request = new HttpRequest();
     $request->setUri('http://example.com/en/');
     $this->event->setLocale('en');
     $this->event->setRequest($request);
     $this->event->setResponse(new HttpResponse());
     $this->strategy->found($this->event);
     $statusCode = $this->event->getResponse()->getStatusCode();
     $header = $this->event->getResponse()->getHeaders()->has('Location');
     $this->assertNotEquals(302, $statusCode);
     $this->assertFalse($header);
 }