function ReverseProxyMiddlewareTest::testNoProxy

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest::testNoProxy()
  2. 8.9.x core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\ReverseProxyMiddlewareTest::testNoProxy()
  3. 11.x 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 41

Class

ReverseProxyMiddlewareTest
Unit test the reverse proxy stack middleware.

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testNoProxy() : void {
    $settings = new Settings([]);
    $this->assertEquals(0, $settings->get('reverse_proxy'));
    $middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $settings);
    // Mock a request object.
    $request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')
        ->onlyMethods([
        'setTrustedProxies',
    ])
        ->getMock();
    // setTrustedProxies() should never fire.
    $request->expects($this->never())
        ->method('setTrustedProxies');
    // Actually call the check method.
    $middleware->handle($request);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.