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:
Diffstat (limited to 'tests/PHPUnit/Integration/Core/Tracker/VisitTest.php')
-rw-r--r--tests/PHPUnit/Integration/Core/Tracker/VisitTest.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/Core/Tracker/VisitTest.php b/tests/PHPUnit/Integration/Core/Tracker/VisitTest.php
index 5c50a8b071..9ddf6647e4 100644
--- a/tests/PHPUnit/Integration/Core/Tracker/VisitTest.php
+++ b/tests/PHPUnit/Integration/Core/Tracker/VisitTest.php
@@ -170,6 +170,7 @@ class Core_Tracker_VisitTest extends DatabaseTestCase
$this->assertSame($expectedIsReferrerSpam, $excluded->public_isReferrerSpamExcluded(), $spamUrl);
}
}
+
/**
* @group Core
* @group IpIsKnownBot
@@ -199,6 +200,58 @@ class Core_Tracker_VisitTest extends DatabaseTestCase
$this->assertSame($isBot, $excluded->public_isNonHumanBot(), $ip);
}
}
+
+ /**
+ * @group Core
+ * @group UserAgentIsKnownBot
+ */
+ public function testIsVisitor_userAgentIsKnownBot()
+ {
+ $isUserAgentBot = array(
+ 'baiduspider' => true,
+ 'bingbot' => true,
+ 'BINGBOT' => true,
+ 'x BingBot x' => true,
+ 'BingPreview' => true,
+ 'facebookexternalhit' => true,
+ 'YottaaMonitor' => true,
+ 'Mozilla/5.0 (compatible; CloudFlare-AlwaysOnline/1.0; +http://www.cloudflare.com/always-online) XXXX' => true,
+ 'Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)' => true,
+ 'Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)' => true,
+ 'Exabot/2.0' => true,
+ 'sogou spider' => true,
+ 'Mozilla/5.0(compatible;Sosospider/2.0;+http://help.soso.com/webspider.htm)' => true,
+
+
+ 'AdsBot-Google (+http://www.google.com/adsbot.html)' => true,
+ 'Google Page Speed Insights' => true,
+ // Web snippets
+ 'Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0 Google (+https://developers.google.com/+/web/snippet/)' => true,
+ // Google Web Preview
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.51 (KHTML, like Gecko; Google Web Preview) Chrome/12.0.742 Safari/534.51' => true,
+ 'Googlebot-Video/1.0' => true,
+ 'Googlebot' => true,
+
+ 'random' => false,
+ 'hello world' => false,
+ 'this is a user agent' => false,
+ 'Mozilla' => false,
+ );
+
+ $idsite = API::getInstance()->addSite("name", "http://piwik.net/");
+
+ foreach ($isUserAgentBot as $userAgent => $isBot) {
+ $request = new Request(array(
+ 'idsite' => $idsite,
+ 'bots' => 0,
+ 'ua' => $userAgent,
+ ));
+
+ $excluded = new VisitExcluded_public($request);
+
+ $this->assertSame($isBot, $excluded->public_isNonHumanBot(), $userAgent);
+ }
+ }
}
class VisitExcluded_public extends VisitExcluded