OneLogin_Saml2_Utils::getBaseURLPath PHP Method

getBaseURLPath() public static method

return string The baseurlpath to be used when constructing URLs
public static getBaseURLPath ( )
    public static function getBaseURLPath()
    {
        return self::$_baseurlpath;
    }

Usage Example

Example #1
0
 /**
  * @covers OneLogin_Saml2_Utils::setBaseURL
  */
 public function testSetBaseURL()
 {
     $_SERVER['HTTP_HOST'] = 'sp.example.com';
     $_SERVER['HTTPS'] = 'https';
     $_SERVER['REQUEST_URI'] = '/example1/route.php?x=test';
     $_SERVER['QUERY_STRING'] = '?x=test';
     $_SERVER['SCRIPT_NAME'] = '/example1/route.php';
     unset($_SERVER['PATH_INFO']);
     $expectedUrlNQ = 'https://sp.example.com/example1/route.php';
     $expectedRoutedUrlNQ = 'https://sp.example.com/example1/route.php';
     $expectedUrl = 'https://sp.example.com/example1/route.php?x=test';
     OneLogin_Saml2_Utils::setBaseURL("no-valid-url");
     $this->assertEquals('https', OneLogin_Saml2_Utils::getSelfProtocol());
     $this->assertEquals('sp.example.com', OneLogin_Saml2_Utils::getSelfHost());
     $this->assertNull(OneLogin_Saml2_Utils::getSelfPort());
     $this->assertNull(OneLogin_Saml2_Utils::getBaseURLPath());
     $this->assertEquals($expectedUrlNQ, OneLogin_Saml2_Utils::getSelfURLNoQuery());
     $this->assertEquals($expectedRoutedUrlNQ, OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery());
     $this->assertEquals($expectedUrl, OneLogin_Saml2_Utils::getSelfURL());
     OneLogin_Saml2_Utils::setBaseURL("http://anothersp.example.com:81/example2/");
     $expectedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php';
     $expectedRoutedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php';
     $expectedUrl2 = 'http://anothersp.example.com:81/example2/route.php?x=test';
     $this->assertEquals('http', OneLogin_Saml2_Utils::getSelfProtocol());
     $this->assertEquals('anothersp.example.com', OneLogin_Saml2_Utils::getSelfHost());
     $this->assertEquals('81', OneLogin_Saml2_Utils::getSelfPort());
     $this->assertEquals('/example2/', OneLogin_Saml2_Utils::getBaseURLPath());
     $this->assertEquals($expectedUrlNQ2, OneLogin_Saml2_Utils::getSelfURLNoQuery());
     $this->assertEquals($expectedRoutedUrlNQ2, OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery());
     $this->assertEquals($expectedUrl2, OneLogin_Saml2_Utils::getSelfURL());
     $_SERVER['PATH_INFO'] = '/test';
     $expectedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php/test';
     $this->assertEquals($expectedUrlNQ2, OneLogin_Saml2_Utils::getSelfURLNoQuery());
     $this->assertEquals($expectedRoutedUrlNQ2, OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery());
     $this->assertEquals($expectedUrl2, OneLogin_Saml2_Utils::getSelfURL());
 }