public function testForwardedWithMultipleFor()
{
$middleware = new IPAddress(true);
$request = ServerRequestFactory::fromGlobals(['REMOTE_ADDR' => '192.168.1.1', 'HTTP_FORWARDED' => 'for=192.0.2.43, for=198.51.100.17;by=203.0.113.60;proto=http;host=example.com']);
$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.0.2.43', $ipAddress);
}