/** * @dataProvider getLong2IPTestData * @group Core * @group IP */ public function testLong2ip($N, $P) { $this->assertEquals($P, Piwik_IP::long2ip($N), bin2hex($N)); // this is our compatibility function $this->assertEquals($P, Piwik_Common::long2ip($N), bin2hex($N)); }
/** * Convert IP address (in network address format) to presentation format. * This is a backward compatibility function for code that only expects * IPv4 addresses (i.e., doesn't support IPv6). * * @see Piwik_IP::N2P() * * This function does not support the long (or its string representation) * returned by the built-in ip2long() function, from Piwik 1.3 and earlier. * * @deprecated 1.4 * * @param string $ip IP address in network address format * @return string */ public static function long2ip($ip) { return Piwik_IP::long2ip($ip); }
function test_long2ip() { // a valid network address is either 4 or 16 bytes; those lines are intentionally left blank ;) $tests = array(null => '0.0.0.0', "" => '0.0.0.0', "" => '127.0.0.1', "��" => '192.168.1.1', "����" => '192.168.1.2', "���" => '0.0.0.0', "��" => '0.0.0.0', "��" => '0.0.0.0', '-1062731520' => '0.0.0.0', '3232235776' => '0.0.0.0', '168430090' => '0.0.0.0', '9999' => '57.57.57.57', "9999" => '57.57.57.57', '999' => '0.0.0.0', "999" => '0.0.0.0'); foreach ($tests as $N => $P) { $this->assertEqual(Piwik_IP::long2ip($N), $P, bin2hex($N)); // this is our compatibility function $this->assertEqual(Piwik_Common::long2ip($N), $P, bin2hex($N)); } }