Пример #1
0
 public function testGetIpAddress()
 {
     $request = new ServerRequest();
     $serverParams = new ServerParams($request);
     static::assertEquals(null, $serverParams->getIpAddress());
     $serverParams = new ServerParams(new ServerRequest(['REMOTE_ADDR' => '0.0.0.1']));
     static::assertEquals('0.0.0.1', $serverParams->getIpAddress());
     $serverParams = new ServerParams($request->withHeader('x-forwarded-for', '0.0.0.2'));
     static::assertEquals('0.0.0.2', $serverParams->getIpAddress());
     $serverParams = new ServerParams((new ServerRequest(['REMOTE_ADDR' => '0.0.0.3']))->withHeader('x-forwarded-for', '0.0.0.4'));
     static::assertEquals('0.0.0.4', $serverParams->getIpAddress());
     // x-forwarded-for first
 }