RKA\Middleware\Test\RendererTest::testCustomHeader PHP Method

testCustomHeader() public method

public testCustomHeader ( )
    public function testCustomHeader()
    {
        $headersToInspect = ['Foo-Bar'];
        $middleware = new IPAddress(true, [], null, $headersToInspect);
        $request = ServerRequestFactory::fromGlobals(['REMOTE_ADDR' => '192.168.0.1']);
        $request = $request->withAddedHeader('Foo-Bar', '192.168.1.3');
        $response = new Response();
        $ipAddress = '123';
        $response = $middleware($request, $response, function ($request, $response) use(&$ipAddress) {
            // simply store the "ip_address" attribute in to the referenced $ipAddress
            $ipAddress = $request->getAttribute('ip_address');
            return $response;
        });
        $this->assertSame('192.168.1.3', $ipAddress);
    }