Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / http-kernel / Tests / EventListener / ValidateRequestListenerTest.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\EventListener;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\EventDispatcher\EventDispatcher;
16 use Symfony\Component\HttpFoundation\Request;
17 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
18 use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener;
19 use Symfony\Component\HttpKernel\HttpKernelInterface;
20 use Symfony\Component\HttpKernel\KernelEvents;
21
22 class ValidateRequestListenerTest extends TestCase
23 {
24     protected function tearDown()
25     {
26         Request::setTrustedProxies(array(), -1);
27     }
28
29     /**
30      * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
31      */
32     public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps()
33     {
34         $dispatcher = new EventDispatcher();
35         $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
36
37         $request = new Request();
38         $request->setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED);
39         $request->server->set('REMOTE_ADDR', '1.1.1.1');
40         $request->headers->set('FORWARDED', 'for=2.2.2.2');
41         $request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
42
43         $dispatcher->addListener(KernelEvents::REQUEST, array(new ValidateRequestListener(), 'onKernelRequest'));
44         $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
45
46         $dispatcher->dispatch(KernelEvents::REQUEST, $event);
47     }
48 }