Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / http-kernel / Tests / Debug / FileLinkFormatterTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpKernel\Tests\Debug;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpFoundation\Request;
16 use Symfony\Component\HttpFoundation\RequestStack;
17 use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
18
19 class FileLinkFormatterTest extends TestCase
20 {
21     public function testWhenNoFileLinkFormatAndNoRequest()
22     {
23         $sut = new FileLinkFormatter();
24
25         $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3));
26     }
27
28     public function testWhenFileLinkFormatAndNoRequest()
29     {
30         $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
31
32         $sut = new FileLinkFormatter('debug://open?url=file://%f&line=%l', new RequestStack());
33
34         $this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3));
35     }
36
37     public function testWhenFileLinkFormatAndRequest()
38     {
39         $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
40         $requestStack = new RequestStack();
41         $request = new Request();
42         $requestStack->push($request);
43
44         $sut = new FileLinkFormatter('debug://open?url=file://%f&line=%l', $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
45
46         $this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3));
47     }
48
49     public function testWhenNoFileLinkFormatAndRequest()
50     {
51         $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
52         $requestStack = new RequestStack();
53         $request = new Request();
54         $requestStack->push($request);
55
56         $request->server->set('SERVER_NAME', 'www.example.org');
57         $request->server->set('SERVER_PORT', 80);
58         $request->server->set('SCRIPT_NAME', '/index.php');
59         $request->server->set('SCRIPT_FILENAME', '/public/index.php');
60         $request->server->set('REQUEST_URI', '/index.php/example');
61
62         $sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
63
64         $this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
65     }
66 }