/**
  * Returns an absolute URL for the passed URI with the current URL
  * as the base path.
  *
  * @param string $uri the absolute or relative URI
  * @return string the absolute URL
  * @throws \Codeception\Exception\TestRuntimeException if either the current
  *         URL or the passed URI can't be parsed
  */
 protected function getAbsoluteUrlFor($uri)
 {
     $currentUrl = $this->getRunningClient()->getHistory()->current()->getUri();
     if (empty($uri) || $uri === '#') {
         return $currentUrl;
     }
     return Uri::mergeUrls($currentUrl, $uri);
 }
Exemple #2
0
 public function getAbsoluteUri($uri)
 {
     $baseUri = $this->client->getConfig('base_uri');
     if (strpos($uri, '://') === false) {
         if (strpos($uri, '/') === 0) {
             $baseUriPath = $baseUri->getPath();
             if (!empty($baseUriPath) && strpos($uri, $baseUriPath) === 0) {
                 $uri = substr($uri, strlen($baseUriPath));
             }
             return Uri::appendPath((string) $baseUri, $uri);
         }
         // relative url
         if (!$this->getHistory()->isEmpty()) {
             return Uri::mergeUrls((string) $this->getHistory()->current()->getUri(), $uri);
         }
     }
     return Uri::mergeUrls($baseUri, $uri);
 }
Exemple #3
0
 public function getAbsoluteUri($uri)
 {
     $baseUri = $this->baseUri;
     if (strpos($uri, '://') === false) {
         if (strpos($uri, '/') === 0) {
             return Uri::appendPath((string) $baseUri, $uri);
         }
         // relative url
         if (!$this->getHistory()->isEmpty()) {
             return Uri::mergeUrls((string) $this->getHistory()->current()->getUri(), $uri);
         }
     }
     return Uri::mergeUrls($baseUri, $uri);
 }