Skip to content
Snippets Groups Projects
Commit 95cba53b authored by Laurent's avatar Laurent
Browse files

dev #14199 exclude bot SISTRIX and VoilaBot

parent 6bdd2616
Branches
Tags
4 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!180Master,!170Dev#14199 Bots Killer,!164Dev#14199 Bots Killer
......@@ -35,7 +35,7 @@ function isTelephone() {
function isUserAgentBot($useragent) {
return false !== strpos(strtoupper($useragent), 'BOT/');
return 0 !== preg_match('/(bot\/|sistrix|voilabot)/i', $useragent);
}
......
......@@ -42,6 +42,40 @@ class BotUserAgentTest extends PHPUnit_Framework_TestCase {
date('H')+1,
date('H')+2));
}
public function botUserAgents() {
return [
['Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)'],
['Mozilla/5.0 (compatible; SISTRIX Crawler; http://crawler.sistrix.net/)'],
['Mozilla/5.0 (Windows NT 5.1; U; Win64; fr; rv:1.8.1) VoilaBot BETA 1.2 (support.voilabot@orange-ftgroup.com)'],
];
}
/**
* @dataProvider botUserAgents
* @test
*/
public function isUserAgentShouldReturnTrueForAgent($agent) {
$this->assertTrue(isUserAgentBot($agent));
}
public function browserUserAgents() {
return [
['Mozilla/5.0'],
['Webkit'],
['Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; )']
];
}
/**
* @dataProvider browserUserAgents
* @test
*/
public function isUserAgentShouldReturnFalseForAgent($agent) {
$this->assertFalse(isUserAgentBot($agent));
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment