You are here

public function ReverseProxyMiddlewareTest::testNoProxy in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest::testNoProxy()

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

File

core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php, line 37
Contains \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest.

Class

ReverseProxyMiddlewareTest
Unit test the reverse proxy stack middleware.

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testNoProxy() {
  $settings = new Settings(array());
  $this
    ->assertEquals(0, $settings
    ->get('reverse_proxy'));
  $middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $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');

  // Actually call the check method.
  $middleware
    ->handle($request);
}