public function testCreateFromServer() { $server = array( 'PHP_SELF' => '', 'REQUEST_URI' => '', 'SERVER_ADDR' => '127.0.0.1', 'HTTPS' => 'on', 'SERVER_PROTOCOL' => 'HTTP', 'SERVER_PORT' => 23, 'HTTP_HOST' => 'example.com', ); $url = UrlImmutable::createFromServer($server); $this->assertInstanceof('\League\Url\UrlImmutable', $url); $this->assertSame('https://example.com:23/', $url->__toString()); $server = array( 'PHP_SELF' => '', 'REQUEST_URI' => '', 'SERVER_ADDR' => '127.0.0.1', 'HTTPS' => 'on', 'SERVER_PROTOCOL' => 'HTTP', 'SERVER_PORT' => 23, ); $url = Url::createFromServer($server); $this->assertInstanceof('\League\Url\Url', $url); $this->assertSame('https://127.0.0.1:23/', $url->__toString()); }
public function __construct() { if (self::$url === null) { self::$url = UrlImmutable::createFromServer($_SERVER); } }