Exemple #1
0
 /**
  * @group Core
  * @group Tracker
  * @group Tracker_Visit
  * @dataProvider getExcludedIpTestData
  */
 public function testIsVisitorIpExcluded($excludedIp, $tests)
 {
     $visit = new Test_Piwik_TrackerVisit_public();
     $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0, $excludedIp);
     $visit->setRequest(array('idsite' => $idsite));
     // test that IPs within the range, or the given IP, are excluded
     foreach ($tests as $ip => $expected) {
         $testIpIsExcluded = Piwik_IP::P2N($ip);
         $this->assertSame($expected, $visit->public_isVisitorIpExcluded($testIpIsExcluded));
     }
 }
Exemple #2
0
 function test_isVisitorIpExcluded()
 {
     $excludedIps = array('12.12.12.12' => array('12.12.12.12' => true, '12.12.12.11' => false, '12.12.12.13' => false, '0.0.0.0' => false, '255.255.255.255' => false), '12.12.12.12/32' => array('12.12.12.12' => true, '12.12.12.11' => false, '12.12.12.13' => false, '0.0.0.0' => false, '255.255.255.255' => false), '12.12.12.*' => array('12.12.12.0' => true, '12.12.12.255' => true, '12.12.12.12' => true, '12.12.11.255' => false, '12.12.13.0' => false, '0.0.0.0' => false, '255.255.255.255' => false), '12.12.12.0/24' => array('12.12.12.0' => true, '12.12.12.255' => true, '12.12.12.12' => true, '12.12.11.255' => false, '12.12.13.0' => false, '0.0.0.0' => false, '255.255.255.255' => false));
     $visit = new Test_Piwik_TrackerVisit_public();
     foreach ($excludedIps as $excludedIp => $tests) {
         $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0, $excludedIp);
         $visit->setRequest(array('idsite' => $idsite));
         // test that IPs within the range, or the given IP, are excluded
         foreach ($tests as $ip => $expected) {
             $testIpIsExcluded = Piwik_IP::P2N($ip);
             $this->assertTrue($visit->public_isVisitorIpExcluded($testIpIsExcluded) === $expected, $ip . " is not excluded in " . $excludedIp);
         }
     }
 }