SimpleSAML\Test\Utils\HTTPTest::testGetSelfHostWithPort PHP Method

testGetSelfHostWithPort() public method

Test SimpleSAML\Utils\HTTP::getSelfHostWithPort(), with and without custom port.
    public function testGetSelfHostWithPort()
    {
        $original = $_SERVER;
        \SimpleSAML_Configuration::loadFromArray(array('baseurlpath' => ''), '[ARRAY]', 'simplesaml');
        // standard port for HTTP
        $_SERVER['SERVER_PORT'] = '80';
        $this->assertEquals('localhost', HTTP::getSelfHostWithNonStandardPort());
        // non-standard port
        $_SERVER['SERVER_PORT'] = '3030';
        $this->assertEquals('localhost:3030', HTTP::getSelfHostWithNonStandardPort());
        // standard port for HTTPS
        $_SERVER['HTTPS'] = 'on';
        $_SERVER['SERVER_PORT'] = '443';
        $this->assertEquals('localhost', HTTP::getSelfHostWithNonStandardPort());
        $_SERVER = $original;
    }