1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Sergey Nehaenko <[email protected]> |
4
|
|
|
* @license GPL |
5
|
|
|
* @copyright Sergey Nehaenko © 2016 |
6
|
|
|
* @version 1.0 |
7
|
|
|
* @project browser-detector |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace EndorphinStudio\Tests; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class RobotTest extends \PHPUnit_Framework_TestCase |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Test Tine RSS |
18
|
|
|
*/ |
19
|
|
|
public function testTinyRSS() |
20
|
|
|
{ |
21
|
|
|
$ualist = array( |
22
|
|
|
'Tiny Tiny RSS/1.10 (http://tt-rss.org/)' |
23
|
|
|
); |
24
|
|
|
|
25
|
|
|
testUaList($this,'Robot','Name',$ualist,'Tiny RSS'); |
26
|
|
|
testUaList($this,'Robot','Type',$ualist,'RSS Reader'); |
27
|
|
|
} |
28
|
|
|
/** |
29
|
|
|
* Test Google Bots |
30
|
|
|
*/ |
31
|
|
View Code Duplication |
public function testGoogleBot() |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
$ualist = array( |
34
|
|
|
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', |
35
|
|
|
'Googlebot/2.1 (+http://www.google.com/bot.html)', |
36
|
|
|
'Googlebot-News', |
37
|
|
|
'Googlebot-Image/1.0', |
38
|
|
|
'Googlebot-Video/1.0', |
39
|
|
|
'SAMSUNG-SGH-E250/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Browser/6.2.3.3.c.1.101 (GUI) MMP/2.0 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)', |
40
|
|
|
'DoCoMo/2.0 N905i(c100;TB;W24H16) (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)', |
41
|
|
|
'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', |
42
|
|
|
'(compatible; Mediapartners-Google/2.1; +http://www.google.com/bot.html)', |
43
|
|
|
'Mediapartners-Google' |
44
|
|
|
); |
45
|
|
|
|
46
|
|
|
testUaList($this,'Robot','Owner',$ualist,'Google Inc.'); |
47
|
|
|
testUaList($this,'Robot','Type',$ualist,'Search Engine'); |
48
|
|
|
testUaListBooleanTrue($this,'Robot','SearchEngine',$ualist); |
49
|
|
|
} |
50
|
|
|
/** |
51
|
|
|
* Test Yandex Bots |
52
|
|
|
*/ |
53
|
|
|
public function testYandexBot() |
54
|
|
|
{ |
55
|
|
|
$ualist = array( |
56
|
|
|
'Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots) ', |
57
|
|
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4 (compatible; YandexBot/3.0; +http://yandex.com/bots)', |
58
|
|
|
'Mozilla/5.0 (compatible; YandexAccessibilityBot/3.0; +http://yandex.com/bots)', |
59
|
|
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4 (compatible; YandexMobileBot/3.0; +http://yandex.com/bots)', |
60
|
|
|
'Mozilla/5.0 (compatible; YandexDirectDyn/1.0; +http://yandex.com/bots', |
61
|
|
|
'Mozilla/5.0 (compatible; YandexScreenshotBot/3.0; +http://yandex.com/bots)', |
62
|
|
|
'Mozilla/5.0 (compatible; YandexImages/3.0; +http://yandex.com/bots)', |
63
|
|
|
'Mozilla/5.0 (compatible; YandexVideo/3.0; +http://yandex.com/bots)', |
64
|
|
|
'Mozilla/5.0 (compatible; YandexMedia/3.0; +http://yandex.com/bots)', |
65
|
|
|
'Mozilla/5.0 (compatible; YandexBlogs/0.99; robot; +http://yandex.com/bots)', |
66
|
|
|
'Mozilla/5.0 (compatible; YandexFavicons/1.0; +http://yandex.com/bots)', |
67
|
|
|
'Mozilla/5.0 (compatible; YandexWebmaster/2.0; +http://yandex.com/bots)', |
68
|
|
|
'Mozilla/5.0 (compatible; YandexPagechecker/1.0; +http://yandex.com/bots)', |
69
|
|
|
'Mozilla/5.0 (compatible; YandexImageResizer/2.0; +http://yandex.com/bots)', |
70
|
|
|
'Mozilla/5.0 (compatible; YandexAdNet/1.0; +http://yandex.com/bots)', |
71
|
|
|
'Mozilla/5.0 (compatible; YandexDirect/3.0; +http://yandex.com/bots)', |
72
|
|
|
'Mozilla/5.0 (compatible; YaDirectFetcher/1.0; Dyatel; +http://yandex.com/bots)', |
73
|
|
|
'Mozilla/5.0 (compatible; YandexCalendar/1.0; +http://yandex.com/bots)', |
74
|
|
|
'Mozilla/5.0 (compatible; YandexSitelinks; Dyatel; +http://yandex.com/bots)', |
75
|
|
|
'Mozilla/5.0 (compatible; YandexMetrika/2.0; +http://yandex.com/bots)', |
76
|
|
|
'Mozilla/5.0 (compatible; YandexNews/3.0; +http://yandex.com/bots)', |
77
|
|
|
'Mozilla/5.0 (compatible; YandexNewslinks; +http://yandex.com/bots)', |
78
|
|
|
'Mozilla/5.0 (compatible; YandexCatalog/3.0; +http://yandex.com/bots)', |
79
|
|
|
'Mozilla/5.0 (compatible; YandexAntivirus/2.0; +http://yandex.com/bots)', |
80
|
|
|
'Mozilla/5.0 (compatible; YandexMarket/1.0; +http://yandex.com/bots)', |
81
|
|
|
'Mozilla/5.0 (compatible; YandexVertis/3.0; +http://yandex.com/bots)', |
82
|
|
|
'Mozilla/5.0 (compatible; YandexForDomain/1.0; +http://yandex.com/bots)', |
83
|
|
|
'Mozilla/5.0 (compatible; YandexBot/3.0; MirrorDetector; +http://yandex.com/bots)', |
84
|
|
|
'Mozilla/5.0 (compatible; YandexSpravBot/1.0; +http://yandex.com/bots)' |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
testUaList($this,'Robot','Owner',$ualist,'Yandex LLC.'); |
88
|
|
|
testUaList($this,'Robot','Type',$ualist,'Search Engine'); |
89
|
|
|
testUaListBooleanTrue($this,'Robot','SearchEngine',$ualist); |
90
|
|
|
} |
91
|
|
|
/** |
92
|
|
|
* Test Bing Bots |
93
|
|
|
*/ |
94
|
|
View Code Duplication |
public function testBingBot() |
|
|
|
|
95
|
|
|
{ |
96
|
|
|
$ualist = array( |
97
|
|
|
'Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)', |
98
|
|
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)', |
99
|
|
|
'Mozilla/5.0 (Windows Phone 8.1; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 530) like Gecko (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)', |
100
|
|
|
'msnbot/2.0b (+http://search.msn.com/msnbot.htm)', |
101
|
|
|
'msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)', |
102
|
|
|
'Mozilla/5.0 (compatible; adidxbot/2.0; +http://www.bing.com/bingbot.htm)', |
103
|
|
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 (compatible; adidxbot/2.0; +http://www.bing.com/bingbot.htm)', |
104
|
|
|
'Mozilla/5.0 (Windows Phone 8.1; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 530) like Gecko (compatible; adidxbot/2.0; +http://www.bing.com/bingbot.htm)', |
105
|
|
|
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534+ (KHTML, like Gecko) BingPreview/1.0b', |
106
|
|
|
'Mozilla/5.0 (Windows Phone 8.1; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 530) like Gecko BingPreview/1.0b' |
107
|
|
|
); |
108
|
|
|
|
109
|
|
|
testUaList($this,'Robot','Name',$ualist,'Bing'); |
110
|
|
|
testUaList($this,'Robot','Type',$ualist,'Search Engine'); |
111
|
|
|
testUaListBooleanTrue($this,'Robot','SearchEngine',$ualist); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.