public function ReverseProxySubscriberUnitTest::testNoProxy

Tests that subscriber does not act when reverse proxy is not set.

File

drupal/core/tests/Drupal/Tests/Core/EventSubscriber/ReverseProxySubscriberUnitTest.php, line 32
Contains \Drupal\Core\EventSubscriber\ReverseProxySubscriberUnitTest.

Class

ReverseProxySubscriberUnitTest
Tests the ReverseProxySubscriber.

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public function testNoProxy() {
  $settings = new Settings(array());
  $this
    ->assertEquals(0, $settings
    ->get('reverse_proxy'));
  $subscriber = new ReverseProxySubscriber($settings);

  // Mock a request object.
  $request = $this
    ->getMock('Symfony\\Component\\HttpFoundation\\Request', array(
    'setTrustedHeaderName',
    'setTrustedProxies',
  ));

  // setTrustedHeaderName() should never fire.
  $request
    ->expects($this
    ->never())
    ->method('setTrustedHeaderName');

  // Mock a response event.
  $event = $this
    ->getMockedEvent($request);

  // Actually call the check method.
  $subscriber
    ->onKernelRequestReverseProxyCheck($event);
}