e74d96de5d5c8bbeabf47c814a648c96a915e7fa
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Utility / ClientUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Utility;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2013 Steffen Kamper (info@sk-typo3.de)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase for the \TYPO3\CMS\Core\Utility\ClientUtility class.
29 *
30 * @author Steffen Kamper <info@sk-typo3.de>
31 */
32 class ClientUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
33
34 /**
35 * backed-up TYPO3_CONF_VARS SC_OPTIONS
36 *
37 * @var array
38 */
39 private $scOptionsBackup = array();
40
41 /**
42 * backed-up T3_VAR callUserFunction
43 *
44 * @var array
45 */
46 private $callUserFunctionBackup = array();
47
48 public function setUp() {
49 $this->scOptionsBackup = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'];
50 $this->callUserFunctionBackup = $GLOBALS['T3_VAR']['callUserFunction'];
51 }
52
53 public function tearDown() {
54 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = $this->scOptionsBackup;
55 $GLOBALS['T3_VAR']['callUserFunction'] = $this->callUserFunctionBackup;
56 }
57
58 //////////////////////////////////////////////////////////
59 // Utility Functions
60 //////////////////////////////////////////////////////////
61 /**
62 * Compares array of UA strings with expected result array of browser/version pair
63 *
64 * @param array $browserStrings array with userAgent strings
65 * @param array $expectedMembers array with expected browser/version for given userAgent strings
66 */
67 private function analyzeUserAgentStrings($browserStrings, $expectedMembers) {
68 $compare = ($expected = array());
69 foreach ($browserStrings as $browserString) {
70 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($browserString);
71 $expected[] = $expectedMembers;
72 $compare[] = array(
73 'browser' => $infoArray['browser'],
74 'version' => substr($infoArray['version'], 0, 1)
75 );
76 }
77 $this->assertEquals($expected, $compare);
78 }
79
80 //////////////////////////////////////////////////////////
81 // Tests concerning getBrowserInfo
82 //////////////////////////////////////////////////////////
83 /**
84 * @test
85 */
86 public function checkBrowserInfoIE6() {
87 $browserStrings = array(
88 'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
89 'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)',
90 'Mozilla/4.0 (compatible; MSIE 6.01; Windows NT 6.0)',
91 'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
92 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
93 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4325)',
94 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)',
95 'Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)',
96 'Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)',
97 'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)',
98 'Mozilla/4.0 (X11; MSIE 6.0; i686; .NET CLR 1.1.4322; .NET CLR 2.0.50727; FDM)',
99 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 6.0)',
100 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.2)',
101 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.0)',
102 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
103 'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)',
104 'Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)',
105 'Mozilla/4.0 (compatible;MSIE 6.0;Windows 98;Q312461)',
106 'Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
107 'Mozilla/4.0 (compatible; U; MSIE 6.0; Windows NT 5.1)',
108 'Mozilla/4.0 (compatible; MSIE 6,0; Windows NT 5,1; SV1; Alexa Toolbar)'
109 );
110 $expectedMembers = array(
111 'browser' => 'msie',
112 'version' => '6'
113 );
114 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
115 }
116
117 /**
118 * @test
119 */
120 public function checkBrowserInfoIE7() {
121 $browserStrings = array(
122 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
123 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; el-GR)',
124 'Mozilla/5.0 (MSIE 7.0; Macintosh; U; SunOS; X11; gu; SV1; InfoPath.2; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)',
125 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; c .NET CLR 3.0.04506; .NET CLR 3.5.30707; InfoPath.1; el-GR)',
126 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; c .NET CLR 3.0.04506; .NET CLR 3.5.30707; InfoPath.1; el-GR)',
127 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; fr-FR)',
128 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; en-US)',
129 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; .NET CLR 2.0.50727)',
130 'Mozilla/4.79 [en] (compatible; MSIE 7.0; Windows NT 5.0; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)',
131 'Mozilla/4.0 (Windows; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
132 'Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1; .NET CLR 3.0.04506.30)',
133 'Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1)',
134 'Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)',
135 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)',
136 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)',
137 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; YPC 3.2.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618)',
138 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; YPC 3.2.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)',
139 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; Media Center PC 5.0; .NET CLR 2.0.50727)',
140 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 3.0.04506)',
141 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET CLR 1.1.4322)'
142 );
143 $expectedMembers = array(
144 'browser' => 'msie',
145 'version' => '7'
146 );
147 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
148 }
149
150 /**
151 * @test
152 */
153 public function checkBrowserInfoIE8() {
154 $browserStrings = array(
155 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)',
156 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8)',
157 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)',
158 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 3.0)',
159 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; msn OptimizedIE8;ZHCN)',
160 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8)',
161 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; Zune 4.0)',
162 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3)',
163 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; yie8)',
164 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; Zune 3.0; MS-RTC LM 8)',
165 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; Zune 4.0)',
166 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8)',
167 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; FDM; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 1.1.4322)',
168 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; FDM)',
169 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 4.0.20402; MS-RTC LM 8)',
170 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; InfoPath.2; MS-RTC LM 8)',
171 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; InfoPath.2)',
172 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3; .NET CLR 4.0.20506)',
173 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)',
174 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; MRA 5.5 (build 02842); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)',
175 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30729)'
176 );
177 $expectedMembers = array(
178 'browser' => 'msie',
179 'version' => '8'
180 );
181 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
182 }
183
184 /**
185 * @test
186 */
187 public function checkGeckoVersion() {
188 $userAgentString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3';
189 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
190 $this->assertEquals('1.9.2.3', $infoArray['all']['gecko']);
191 }
192
193 /**
194 * @test
195 */
196 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows7() {
197 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)';
198 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
199 $this->assertContains('win7', $infoArray['all_systems']);
200 }
201
202 /**
203 * @test
204 */
205 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() {
206 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)';
207 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
208 $this->assertContains('winVista', $infoArray['all_systems']);
209 }
210
211 /**
212 * @test
213 */
214 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() {
215 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
216 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
217 $this->assertContains('winXP', $infoArray['all_systems']);
218 }
219
220 /**
221 * @test
222 */
223 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() {
224 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
225 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
226 $this->assertContains('win2k', $infoArray['all_systems']);
227 }
228
229 /**
230 * @test
231 */
232 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() {
233 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
234 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
235 $this->assertContains('win2k', $infoArray['all_systems']);
236 }
237
238 /**
239 * @test
240 */
241 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() {
242 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)';
243 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
244 $this->assertContains('winNT', $infoArray['all_systems']);
245 }
246
247 /**
248 * @test
249 */
250 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() {
251 $userAgentString = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7W367a Safari/531.21.10';
252 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
253 $this->assertContains('iOS', $infoArray['all_systems']);
254 }
255
256 /**
257 * @test
258 */
259 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() {
260 $userAgentString = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7';
261 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
262 $this->assertContains('iOS', $infoArray['all_systems']);
263 }
264
265 /**
266 * @test
267 */
268 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() {
269 $userAgentString = 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Geckto) Version/3.0 Mobile/3A101a Safari/419.3';
270 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
271 $this->assertContains('iOS', $infoArray['all_systems']);
272 }
273
274 /**
275 * @test
276 */
277 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() {
278 $userAgentString = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/534.15+ (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4';
279 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
280 $this->assertContains('mac', $infoArray['all_systems']);
281 }
282
283 /**
284 * @test
285 */
286 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() {
287 $userAgentString = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8';
288 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
289 $this->assertContains('linux', $infoArray['all_systems']);
290 }
291
292 /**
293 * @test
294 */
295 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() {
296 $userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9';
297 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
298 $this->assertContains('unix_sun', $infoArray['all_systems']);
299 }
300
301 /**
302 * Provide various user agent strings for android devices
303 *
304 * @static
305 * @return array List of user agents
306 */
307 static public function androidUserAgentsProvider() {
308 $agents = array(
309 'defaultBrowser' => array(
310 'agent' => 'Mozilla/5.0 (Linux; U; Android 2.3; en-US; sdk Build/GRH55) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'
311 ),
312 'operaMini' => array(
313 'agent' => 'Opera/9.80 (Android; Opera Mini/6.0.24556/24.816; U; en) Presto/2.5.25 Version/10.54'
314 )
315 );
316 return $agents;
317 }
318
319 /**
320 * @test
321 * @dataProvider androidUserAgentsProvider
322 */
323 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid($userAgentString) {
324 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
325 $this->assertContains('android', $infoArray['all_systems']);
326 }
327
328 /**
329 * @test
330 */
331 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfOpenbsd() {
332 $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)';
333 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
334 $this->assertContains('unix_bsd', $infoArray['all_systems']);
335 }
336
337 /**
338 * @test
339 */
340 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfNetbsd() {
341 $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)';
342 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
343 $this->assertContains('unix_bsd', $infoArray['all_systems']);
344 }
345
346 /**
347 * @test
348 */
349 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfFreebsd() {
350 $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2';
351 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
352 $this->assertContains('unix_bsd', $infoArray['all_systems']);
353 }
354
355 /**
356 * @test
357 */
358 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfChromeOs() {
359 $userAgentString = 'Mozilla/5.0 (X11; U; CrOS i686 9.10.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.253.0 Safari 532.5';
360 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
361 $this->assertContains('chrome', $infoArray['all_systems']);
362 }
363
364 /**
365 * @test
366 */
367 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfSafari() {
368 $userAgentString = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9';
369 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
370 $this->assertSame('safari', $infoArray['browser']);
371 }
372
373 /**
374 * @test
375 */
376 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfFirefox() {
377 $userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8';
378 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
379 $this->assertSame('firefox', $infoArray['browser']);
380 }
381
382 /**
383 * @test
384 */
385 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfOpera() {
386 $userAgentString = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE amd64; U; en) Presto/2.2.15 Version/10.10';
387 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
388 $this->assertSame('opera', $infoArray['browser']);
389 }
390
391 /**
392 * @test
393 */
394 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnAndroid() {
395 $userAgentString = 'Mozilla/5.0 (Linux; U; Android WildPuzzleROM v8.0.7 froyo 2.2; de-de; HTC Wildfire Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1';
396 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
397 $this->assertSame('safari', $infoArray['browser']);
398 }
399
400 /**
401 * @test
402 */
403 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnIphone() {
404 $userAgentString = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5';
405 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
406 $this->assertSame('safari', $infoArray['browser']);
407 }
408
409 /**
410 * @test
411 */
412 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfKonqueror() {
413 $userAgentString = 'Mozilla/5.0 (compatible; Konqueror/4.4; FreeBSD) KHTML/4.4.5 (like Gecko)';
414 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
415 $this->assertSame('konqueror', $infoArray['browser']);
416 }
417
418 }