@@ -1883,6 +1883,62 @@ public static function getBaseUrlData()
1883
1883
];
1884
1884
}
1885
1885
1886
+ /**
1887
+ * @dataProvider baseUriDetectionOnIisWithRewriteData
1888
+ */
1889
+ public function testBaseUriDetectionOnIisWithRewrite (array $ server , string $ expectedBaseUrl , string $ expectedPathInfo )
1890
+ {
1891
+ $ request = new Request ([], [], [], [], [], $ server );
1892
+
1893
+ self ::assertSame ($ expectedBaseUrl , $ request ->getBaseUrl ());
1894
+ self ::assertSame ($ expectedPathInfo , $ request ->getPathInfo ());
1895
+ }
1896
+
1897
+ public static function baseUriDetectionOnIisWithRewriteData (): \Generator
1898
+ {
1899
+ yield 'No rewrite ' => [
1900
+ [
1901
+ 'PATH_INFO ' => '/foo/bar ' ,
1902
+ 'PHP_SELF ' => '/routingtest/index.php/foo/bar ' ,
1903
+ 'REQUEST_URI ' => '/routingtest/index.php/foo/bar ' ,
1904
+ 'SCRIPT_FILENAME ' => 'C:/Users/derrabus/Projects/routing-test/public/index.php ' ,
1905
+ 'SCRIPT_NAME ' => '/routingtest/index.php ' ,
1906
+ ],
1907
+ '/routingtest/index.php ' ,
1908
+ '/foo/bar ' ,
1909
+ ];
1910
+
1911
+ yield 'Rewrite with correct case ' => [
1912
+ [
1913
+ 'IIS_WasUrlRewritten ' => '1 ' ,
1914
+ 'PATH_INFO ' => '/foo/bar ' ,
1915
+ 'PHP_SELF ' => '/routingtest/index.php/foo/bar ' ,
1916
+ 'REQUEST_URI ' => '/routingtest/foo/bar ' ,
1917
+ 'SCRIPT_FILENAME ' => 'C:/Users/derrabus/Projects/routing-test/public/index.php ' ,
1918
+ 'SCRIPT_NAME ' => '/routingtest/index.php ' ,
1919
+ 'UNENCODED_URL ' => '/routingtest/foo/bar ' ,
1920
+ ],
1921
+ '/routingtest ' ,
1922
+ '/foo/bar ' ,
1923
+ ];
1924
+
1925
+ // ISS with UrlRewriteModule might report SCRIPT_NAME/PHP_SELF with wrong case
1926
+ // see https://github.com/php/php-src/issues/11981
1927
+ yield 'Rewrite with case mismatch ' => [
1928
+ [
1929
+ 'IIS_WasUrlRewritten ' => '1 ' ,
1930
+ 'PATH_INFO ' => '/foo/bar ' ,
1931
+ 'PHP_SELF ' => '/routingtest/index.php/foo/bar ' ,
1932
+ 'REQUEST_URI ' => '/RoutingTest/foo/bar ' ,
1933
+ 'SCRIPT_FILENAME ' => 'C:/Users/derrabus/Projects/routing-test/public/index.php ' ,
1934
+ 'SCRIPT_NAME ' => '/routingtest/index.php ' ,
1935
+ 'UNENCODED_URL ' => '/RoutingTest/foo/bar ' ,
1936
+ ],
1937
+ '/RoutingTest ' ,
1938
+ '/foo/bar ' ,
1939
+ ];
1940
+ }
1941
+
1886
1942
/**
1887
1943
* @dataProvider urlencodedStringPrefixData
1888
1944
*/
0 commit comments