Файл: gapps/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
Строк: 101
<?php
/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace SymfonyComponentHttpKernelTestsEventListener;
use SymfonyComponentEventDispatcherEventDispatcher;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpKernelEventListenerValidateRequestListener;
use SymfonyComponentHttpKernelEventGetResponseEvent;
use SymfonyComponentHttpKernelHttpKernelInterface;
use SymfonyComponentHttpKernelKernelEvents;
class ValidateRequestListenerTest extends PHPUnit_Framework_TestCase
{
    /**
     * @expectedException SymfonyComponentHttpFoundationExceptionConflictingHeadersException
     */
    public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps()
    {
        $dispatcher = new EventDispatcher();
        $kernel = $this->getMock('SymfonyComponentHttpKernelHttpKernelInterface');
        $request = new Request();
        $request->setTrustedProxies(array('1.1.1.1'));
        $request->server->set('REMOTE_ADDR', '1.1.1.1');
        $request->headers->set('FORWARDED', '2.2.2.2');
        $request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
        $dispatcher->addListener(KernelEvents::REQUEST, array(new ValidateRequestListener(), 'onKernelRequest'));
        $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
        $dispatcher->dispatch(KernelEvents::REQUEST, $event);
    }
}