@@ -547,6 +547,47 @@ public function testSetBaseURL()
547547 $ this ->assertEquals ('/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
548548 }
549549
550+ /**
551+ * @covers OneLogin_Saml2_Utils::setBaseURL
552+ */
553+ public function testSetBaseURL2 ()
554+ {
555+ $ _SERVER ['HTTP_HOST ' ] = 'sp.example.com ' ;
556+ $ _SERVER ['HTTPS ' ] = 'https ' ;
557+ $ _SERVER ['REQUEST_URI ' ] = null ;
558+ $ _SERVER ['QUERY_STRING ' ] = null ;
559+ $ _SERVER ['SCRIPT_NAME ' ] = '/ ' ;
560+ unset($ _SERVER ['PATH_INFO ' ]);
561+
562+ OneLogin_Saml2_Utils::setBaseURL ('https://sp.example.com ' );
563+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfURLNoQuery ());
564+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
565+ $ this ->assertEquals ("https://sp.example.com/ " , OneLogin_Saml2_Utils::getSelfURL ());
566+ $ this ->assertEquals ('/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
567+
568+ $ _SERVER ['REQUEST_URI ' ] = '/example1/path/route.php?x=test ' ;
569+ $ _SERVER ['QUERY_STRING ' ] = '?x=test ' ;
570+ $ _SERVER ['SCRIPT_NAME ' ] = '/example1/path/route.php ' ;
571+ $ this ->assertEquals ("https://sp.example.com/example1/path/route.php " , OneLogin_Saml2_Utils::getSelfURLNoQuery ());
572+ $ this ->assertEquals ("https://sp.example.com/example1/path/route.php " , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
573+ $ this ->assertEquals ("https://sp.example.com/example1/path/route.php?x=test " , OneLogin_Saml2_Utils::getSelfURL ());
574+ $ this ->assertEquals ('/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
575+
576+ OneLogin_Saml2_Utils::setBaseURLPath ('/example1/path/ ' );
577+ $ this ->assertEquals ("https://sp.example.com/example1/path/route.php " , OneLogin_Saml2_Utils::getSelfURLNoQuery ());
578+ $ this ->assertEquals ("https://sp.example.com/example1/path/route.php " , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
579+ $ this ->assertEquals ("https://sp.example.com/example1/path/route.php?x=test " , OneLogin_Saml2_Utils::getSelfURL ());
580+ $ this ->assertEquals ('/example1/path/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
581+
582+ $ _SERVER ['REQUEST_URI ' ] = '/example1/path/route/?x=test ' ;
583+ $ _SERVER ['QUERY_STRING ' ] = '?x=test ' ;
584+ $ _SERVER ['SCRIPT_NAME ' ] = '/example1/path/route ' ;
585+ $ this ->assertEquals ("https://sp.example.com/example1/path/route " , OneLogin_Saml2_Utils::getSelfURLNoQuery ());
586+ $ this ->assertEquals ("https://sp.example.com/example1/path/route " , OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery ());
587+ $ this ->assertEquals ("https://sp.example.com/example1/path/route/?x=test " , OneLogin_Saml2_Utils::getSelfURL ());
588+ $ this ->assertEquals ('/example1/path/ ' , OneLogin_Saml2_Utils::getBaseURLPath ());
589+ }
590+
550591 /**
551592 * Tests the getSelfURLhost method of the OneLogin_Saml2_Utils
552593 *
0 commit comments