/** * 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 testGetUrlByRouteName() { $routes = ['fake' => ['pattern' => '/fake/{param1}/{param2}', 'defaults' => []]]; // 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']); $routeCollection = new RouteCollection(self::$app); $routeCollection->pushRouteCollection($routes); $this->assertEquals('https://www.fakeserver.com/public/fake/1/2.html', $routeCollection->getUrlByRouteName('fake', ['param1' => '1', 'param2' => '2'])); $this->assertEquals('https://www.fakeserver.com/public/fake/1/2.html', $routeCollection->getUrlByRouteName('fake', ['param1' => '1', 'param2' => '2', 'param3' => '3'])); $this->assertEquals('https://www.fakeserver.com/public/fake/1/2.html?param3=3', $routeCollection->getUrlByRouteName('fake', ['param1' => '1', 'param2' => '2', 'param3' => '3'], null, true, null, true)); $this->assertEquals('https://www.fakeserver.com/public/test/fake/1/2.html', $routeCollection->getUrlByRouteName('fake', ['param1' => '1', 'param2' => '2'], '/test')); $this->assertEquals('https://www.fakeserver.com/public/fake/1/2', $routeCollection->getUrlByRouteName('fake', ['param1' => '1', 'param2' => '2'], null, false)); }