This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -489,6 +489,11 @@ protected function detectBaseUrl()
489
489
// Backtrack up the SCRIPT_FILENAME to find the portion
490
490
// matching PHP_SELF.
491
491
492
+ $ argv = $ this ->getServer ()->get ('argv ' , []);
493
+ if (isset ($ argv [0 ]) && strpos ($ filename , $ argv [0 ]) === 0 ) {
494
+ $ filename = substr ($ filename , strlen ($ argv [0 ]));
495
+ }
496
+
492
497
$ baseUrl = '/ ' ;
493
498
$ basename = basename ($ filename );
494
499
if ($ basename ) {
Original file line number Diff line number Diff line change @@ -791,4 +791,18 @@ public function testDetectBaseUrlDoesNotRaiseErrorOnEmptyBaseUrl()
791
791
// If no baseUrl is detected at all, an empty string is returned.
792
792
$ this ->assertEquals ('' , $ url );
793
793
}
794
+
795
+ public function testDetectCorrectBaseUrlForConsoleRequests ()
796
+ {
797
+ $ _SERVER ['argv ' ] = ['/home/user/package/vendor/bin/phpunit ' ];
798
+ $ _SERVER ['argc ' ] = 1 ;
799
+ $ _SERVER ['SCRIPT_FILENAME ' ] = '/home/user/package/vendor/bin/phpunit ' ;
800
+ $ _SERVER ['SCRIPT_NAME ' ] = '/home/user/package/vendor/bin/phpunit ' ;
801
+ $ _SERVER ['PHP_SELF ' ] = '/home/user/package/vendor/bin/phpunit ' ;
802
+
803
+ $ request = new Request ();
804
+ $ request ->setRequestUri ('/path/query/phpunit ' );
805
+
806
+ $ this ->assertSame ('' , $ request ->getBaseUrl ());
807
+ }
794
808
}
You can’t perform that action at this time.
0 commit comments