change baseUrl to basePath to fix wrong profiler url

This commit is contained in:
Smaine Milianni 2018-08-09 22:49:22 +02:00 committed by Fabien Potencier
parent 9a97ea819a
commit 897615ee0d
2 changed files with 5 additions and 6 deletions

View File

@ -100,7 +100,7 @@ class FileLinkFormatter implements \Serializable
} }
return array( return array(
$request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat,
$this->baseDir.\DIRECTORY_SEPARATOR, '', $this->baseDir.\DIRECTORY_SEPARATOR, '',
); );
} }

View File

@ -37,7 +37,6 @@ class FileLinkFormatterTest extends TestCase
public function testWhenFileLinkFormatAndRequest() public function testWhenFileLinkFormatAndRequest()
{ {
$file = __DIR__.\DIRECTORY_SEPARATOR.'file.php'; $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
$baseDir = __DIR__;
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$request = new Request(); $request = new Request();
$requestStack->push($request); $requestStack->push($request);
@ -56,12 +55,12 @@ class FileLinkFormatterTest extends TestCase
$request->server->set('SERVER_NAME', 'www.example.org'); $request->server->set('SERVER_NAME', 'www.example.org');
$request->server->set('SERVER_PORT', 80); $request->server->set('SERVER_PORT', 80);
$request->server->set('SCRIPT_NAME', '/app.php'); $request->server->set('SCRIPT_NAME', '/index.php');
$request->server->set('SCRIPT_FILENAME', '/web/app.php'); $request->server->set('SCRIPT_FILENAME', '/public/index.php');
$request->server->set('REQUEST_URI', '/app.php/example'); $request->server->set('REQUEST_URI', '/index.php/example');
$sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); $sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
$this->assertSame('http://www.example.org/app.php/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3)); $this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
} }
} }