Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsgiehl <stefangiehl@gmail.com>2012-10-19 21:47:37 +0400
committersgiehl <stefangiehl@gmail.com>2012-10-19 21:47:37 +0400
commit5762ad9e177d844593032133c99881417f56de5b (patch)
tree81bc88f1f37699f828bf38a15e66e7d3f9f9aa14 /plugins/AnonymizeIP
parent389c28f97b53cd37d0719366aaa3ada479d7c053 (diff)
refs #3227 removing plugin simple tests
git-svn-id: http://dev.piwik.org/svn/trunk@7240 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins/AnonymizeIP')
-rw-r--r--plugins/AnonymizeIP/tests/AnonymizeIP.test.php58
1 files changed, 0 insertions, 58 deletions
diff --git a/plugins/AnonymizeIP/tests/AnonymizeIP.test.php b/plugins/AnonymizeIP/tests/AnonymizeIP.test.php
deleted file mode 100644
index 84de5d5ba0..0000000000
--- a/plugins/AnonymizeIP/tests/AnonymizeIP.test.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
-{
- require_once dirname(__FILE__)."/../../../tests/config_test.php";
-}
-
-if(!class_exists('Piwik_AnonymizeIP', false))
-{
- require_once dirname(__FILE__) . '/../AnonymizeIP.php';
-}
-
-class Test_Piwik_AnonymizeIP extends UnitTestCase
-{
- // IPv4 addresses and expected results
- protected $ipv4Addresses = array(
- // ip => array( expected0, expected1, expected2, expected3, expected4 ),
- '0.0.0.0' => array( "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.0.1' => array( "\x00\x00\x00\x01", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.0.255' => array( "\x00\x00\x00\xff", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.1.0' => array( "\x00\x00\x01\x00", "\x00\x00\x01\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.1.1' => array( "\x00\x00\x01\x01", "\x00\x00\x01\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.0.255.255' => array( "\x00\x00\xff\xff", "\x00\x00\xff\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.1.0.0' => array( "\x00\x01\x00\x00", "\x00\x01\x00\x00", "\x00\x01\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.1.1.1' => array( "\x00\x01\x01\x01", "\x00\x01\x01\x00", "\x00\x01\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '0.255.255.255' => array( "\x00\xff\xff\xff", "\x00\xff\xff\x00", "\x00\xff\x00\x00", "\x00\x00\x00\x00", "\x00\x00\x00\x00" ),
- '1.0.0.0' => array( "\x01\x00\x00\x00", "\x01\x00\x00\x00", "\x01\x00\x00\x00", "\x01\x00\x00\x00", "\x00\x00\x00\x00" ),
- '127.255.255.255' => array( "\x7f\xff\xff\xff", "\x7f\xff\xff\x00", "\x7f\xff\x00\x00", "\x7f\x00\x00\x00", "\x00\x00\x00\x00" ),
- '128.0.0.0' => array( "\x80\x00\x00\x00", "\x80\x00\x00\x00", "\x80\x00\x00\x00", "\x80\x00\x00\x00", "\x00\x00\x00\x00" ),
- '255.255.255.255' => array( "\xff\xff\xff\xff", "\xff\xff\xff\x00", "\xff\xff\x00\x00", "\xff\x00\x00\x00", "\x00\x00\x00\x00" ),
- );
-
- public function test_applyIPMask()
- {
- foreach($this->ipv4Addresses as $ip => $expected)
- {
- // each IP is tested with 0 to 4 octets masked
- for($maskLength = 0; $maskLength <= 4; $maskLength++)
- {
- $res = Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N($ip), $maskLength);
- $this->assertEqual( $res, $expected[$maskLength], "Got ".bin2hex($res).", Expected " . bin2hex($expected[$maskLength]) );
- }
-
- // edge case (bounds check)
- $this->assertEqual( Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N($ip), 5), "\x00\x00\x00\x00", $ip );
-
- // mask IPv4 mapped addresses
- for($maskLength = 0; $maskLength <= 4; $maskLength++)
- {
- $res = Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N('::ffff:'.$ip), $maskLength);
- $this->assertEqual( $res, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff".$expected[$maskLength], "Got ".bin2hex($res).", Expected " . bin2hex($expected[$maskLength]) );
- }
- $this->assertEqual( Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N('::ffff:'.$ip), 5), "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00", $ip );
-
- // edge case (bounds check)
- $this->assertEqual( Piwik_AnonymizeIP::applyIPMask(Piwik_IP::P2N('2001::ffff:'.$ip), 17), "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", $ip );
- }
- }
-}