You are here

public function ShareaholicSeqShareCountsTest::testGetClientIp in Share Buttons, Related Posts, Content Analytics - Shareaholic 8

Same name and namespace in other branches
  1. 7.3 lib/social-share-counts/seq_share_count_test.php \ShareaholicSeqShareCountsTest::testGetClientIp()

File

lib/social-share-counts/seq_share_count_test.php, line 42

Class

ShareaholicSeqShareCountsTest

Code

public function testGetClientIp() {
  $expected = '12345';
  $_SERVER['HTTP_CLIENT_IP'] = $expected;
  $result = $this->share_count
    ->get_client_ip();
  $this
    ->assertEquals($expected, $result);
  $expected = '23456';
  $_SERVER['HTTP_CLIENT_IP'] = '';
  $_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
  $result = $this->share_count
    ->get_client_ip();
  $this
    ->assertEquals($expected, $result);
  $expected = '34567';
  $_SERVER['HTTP_CLIENT_IP'] = '';
  $_SERVER['HTTP_X_FORWARDED_FOR'] = '';
  $_SERVER['REMOTE_ADDR'] = $expected;
  $result = $this->share_count
    ->get_client_ip();
  $this
    ->assertEquals($expected, $result);
}