/**
  * Returns the icon URL.
  *
  * @param  string      $pathinfo  The pathinfo to treate.
  * @param  int|null    $urlType   Optional, the URL prefix to use.
  *
  * @return string                 The icon URL.
  */
 private function getUri($pathinfo, $urlType = RouteCollection::DEFAULT_URL)
 {
     return $this->routeCollection->getUri($pathinfo, null, null, $urlType);
 }
 public function testGetUriRequested()
 {
     // Starting with a site without servername and simulate an HTTPS request
     $site = new Site();
     self::$app->getContainer()->set('site', $site);
     unset($GLOBALS['argv']);
     self::$app->setIsStarted(true);
     $request = self::$app->getRequest();
     $request->server->add(['SCRIPT_URL' => '/public/fake/fake.html', 'SCRIPT_URI' => 'https://www.fakeserver.com/public/fake/fake.html', 'HTTP_HOST' => 'www.fakeserver.com', 'SERVER_NAME' => 'www.fakeserver.com', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '443', 'HTTPS' => 'on', 'DOCUMENT_ROOT' => '/home/web/fakeroot', 'SCRIPT_FILENAME' => '/home/web/fakeroot/public/index.php', 'REQUEST_URI' => '/public/fake/fake.html', 'SCRIPT_NAME' => '/public/index.php']);
     // No site provided, the request is used
     $routeCollection = new RouteCollection(self::$app);
     $this->assertEquals('http://www.backbee.com', $routeCollection->getUri('http://www.backbee.com'));
     $this->assertEquals('https://www.fakeserver.com/public/', $routeCollection->getUri());
     $this->assertEquals('https://www.fakeserver.com/public/images/', $routeCollection->getUri(null, null, null, RouteCollection::IMAGE_URL));
     $this->assertEquals('https://www.fakeserver.com/public/', $routeCollection->getUri(null, '.html'));
     $this->assertEquals('https://www.fakeserver.com/public/fake.html', $routeCollection->getUri('/fake'));
     $this->assertEquals('https://www.fakeserver.com/public/fake.htm', $routeCollection->getUri('fake.htm', '.html'));
     $this->assertEquals('https://www.fakeserver.com/public/fake.html', $routeCollection->getUri('fake', '.html'));
     // A site is provided, the base URL and the protocol can't be predicted
     $otherSite = new Site();
     $otherSite->setServerName('other.fakeserver.com');
     $this->assertEquals('http://www.backbee.com', $routeCollection->getUri('http://www.backbee.com', null, $otherSite));
     $this->assertEquals('http://other.fakeserver.com/', $routeCollection->getUri(null, null, $otherSite));
     $this->assertEquals('http://other.fakeserver.com/images/', $routeCollection->getUri(null, null, $otherSite, RouteCollection::IMAGE_URL));
     $this->assertEquals('http://other.fakeserver.com/', $routeCollection->getUri(null, '.html', $otherSite));
     $this->assertEquals('http://other.fakeserver.com/fake.html', $routeCollection->getUri('/fake', null, $otherSite));
     $this->assertEquals('http://other.fakeserver.com/fake.htm', $routeCollection->getUri('fake.htm', '.html', $otherSite));
     $this->assertEquals('http://other.fakeserver.com/fake.html', $routeCollection->getUri('fake', '.html', $otherSite));
 }