* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Tests\Debug; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; class FileLinkFormatterTest extends TestCase { public function testWhenNoFileLinkFormatAndNoRequest() { $sut = new FileLinkFormatter(); $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3)); } public function testWhenFileLinkFormatAndNoRequest() { $file = __DIR__.DIRECTORY_SEPARATOR.'file.php'; $sut = new FileLinkFormatter('debug://open?url=file://%f&line=%l', new RequestStack()); $this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3)); } public function testWhenFileLinkFormatAndRequest() { $file = __DIR__.DIRECTORY_SEPARATOR.'file.php'; $baseDir = __DIR__; $requestStack = new RequestStack(); $request = new Request(); $requestStack->push($request); $sut = new FileLinkFormatter('debug://open?url=file://%f&line=%l', $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); $this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3)); } public function testWhenNoFileLinkFormatAndRequest() { $file = __DIR__.DIRECTORY_SEPARATOR.'file.php'; $requestStack = new RequestStack(); $request = new Request(); $requestStack->push($request); $request->server->set('SERVER_NAME', 'www.example.org'); $request->server->set('SERVER_PORT', 80); $request->server->set('SCRIPT_NAME', '/app.php'); $request->server->set('SCRIPT_FILENAME', '/web/app.php'); $request->server->set('REQUEST_URI', '/app.php/example'); $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)); } } __halt_compiler();----SIGNATURE:----r+9AvvL1r9P89QfhAuk6VqGiaaoTJHgLiTC6MplMvlhN6Fq/lmhzTECjuVsFG5eFZ8AovC2xCuELYhqaJ5uMvGRD6W5UNRlv8/v1ePzkZcDviCIOVWahR6nRXG/efXb9iqchYWqUw4iUC9oNyF8JB4a3D73Fvas3CwamH+7us6wOycs817aN+TWjT1V9nsLC/OoiHF6PgqX9NL8vwGwDGL/usHDOAjZ5PElXehMUeosf56k1cl6rwX06eg0jgQeJU7TRBJAEKvPolgd0m2Qhi3Jwo2CUiROJaruDFMNOLbw9BYYgOlH/Eul9GBkc6ygYT46bvg0SojJtuoLpWORhoTCBDhuyKMPLOP3oZfT2stULOciqmnHDnbO7TkdA2ECoCvIgWTUXKoM+BUbX+5PXmLjA9nDDVzYl9J4zsKzvrZYHKFFv5fhr3sxGs5KDjH1mtE8Hb94IBhVbA2YCa6OIAa2ISk0FDgFjNEqelkmw5Z5ABN1+9Qix1TiDFAtPCcmYtC25mBYAyekPRPINc1qk5djtXQxGeELPHPALjCATY5gRdAGwZqwV6aq2V28psBgFYsUvm1G2OndbPwzxsqDJ98Je1JJADeHDObrL5+QcJpg/Ik38UZIsO0lmwJDhjV1Va0yqY1AtiHmRMu6TMQHUvig0rcq9qw8NMsqwEa37vQs=----ATTACHMENT:----MTE3MzI0MzIxMDIyMDc0MSA0MTM0MjUxNjcwNzcxODExIDkzMTIxNTI4OTI1NzQzNDg=