@@ -1867,6 +1867,62 @@ public static function getBaseUrlData()
18671867 ];
18681868 }
18691869
1870+ /**
1871+ * @dataProvider baseUriDetectionOnIisWithRewriteData
1872+ */
1873+ public function testBaseUriDetectionOnIisWithRewrite (array $ server , string $ expectedBaseUrl , string $ expectedPathInfo )
1874+ {
1875+ $ request = new Request ([], [], [], [], [], $ server );
1876+
1877+ self ::assertSame ($ expectedBaseUrl , $ request ->getBaseUrl ());
1878+ self ::assertSame ($ expectedPathInfo , $ request ->getPathInfo ());
1879+ }
1880+
1881+ public static function baseUriDetectionOnIisWithRewriteData (): \Generator
1882+ {
1883+ yield 'No rewrite ' => [
1884+ [
1885+ 'PATH_INFO ' => '/foo/bar ' ,
1886+ 'PHP_SELF ' => '/routingtest/index.php/foo/bar ' ,
1887+ 'REQUEST_URI ' => '/routingtest/index.php/foo/bar ' ,
1888+ 'SCRIPT_FILENAME ' => 'C:/Users/derrabus/Projects/routing-test/public/index.php ' ,
1889+ 'SCRIPT_NAME ' => '/routingtest/index.php ' ,
1890+ ],
1891+ '/routingtest/index.php ' ,
1892+ '/foo/bar ' ,
1893+ ];
1894+
1895+ yield 'Rewrite with correct case ' => [
1896+ [
1897+ 'IIS_WasUrlRewritten ' => '1 ' ,
1898+ 'PATH_INFO ' => '/foo/bar ' ,
1899+ 'PHP_SELF ' => '/routingtest/index.php/foo/bar ' ,
1900+ 'REQUEST_URI ' => '/routingtest/foo/bar ' ,
1901+ 'SCRIPT_FILENAME ' => 'C:/Users/derrabus/Projects/routing-test/public/index.php ' ,
1902+ 'SCRIPT_NAME ' => '/routingtest/index.php ' ,
1903+ 'UNENCODED_URL ' => '/routingtest/foo/bar ' ,
1904+ ],
1905+ '/routingtest ' ,
1906+ '/foo/bar ' ,
1907+ ];
1908+
1909+ // ISS with UrlRewriteModule might report SCRIPT_NAME/PHP_SELF with wrong case
1910+ // see https://github.com/php/php-src/issues/11981
1911+ yield 'Rewrite with case mismatch ' => [
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+
18701926 /**
18711927 * @dataProvider urlencodedStringPrefixData
18721928 */
0 commit comments