[BUGFIX] Detect Android systems properly
[Packages/TYPO3.CMS.git] / tests / t3lib / utility / class.t3lib_utility_clientTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Steffen Kamper (info@sk-typo3.de)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Testcase for the t3lib_utility_Client class.
27 *
28 * @package TYPO3
29 * @subpackage t3lib
30 *
31 * @author Steffen Kamper <info@sk-typo3.de>
32 */
33 class t3lib_utility_clientTest extends tx_phpunit_testcase {
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 //////////////////////////////////////////////////////////
60 // Utility Functions
61 //////////////////////////////////////////////////////////
62
63
64 /**
65 * Compares array of UA strings with expected result array of browser/version pair
66 *
67 * @param array $browserStrings array with userAgent strings
68 * @param array $expectedMembers array with expected browser/version for given userAgent strings
69 */
70 private function analyzeUserAgentStrings($browserStrings, $expectedMembers) {
71 $compare = $expected = array();
72 foreach ($browserStrings as $browserString) {
73 $infoArray = t3lib_utility_Client::getBrowserInfo($browserString);
74 $expected[] = $expectedMembers;
75 $compare[] = array(
76 'browser' => $infoArray['browser'],
77 'version' => substr($infoArray['version'], 0, 1)
78 );
79 }
80 $this->assertEquals(
81 $expected,
82 $compare
83 );
84 }
85
86
87 //////////////////////////////////////////////////////////
88 // Tests concerning t3lib_utility_Client::getBrowserInfo
89 //////////////////////////////////////////////////////////
90
91 /**
92 * @test
93 */
94 public function checkBrowserInfoIE6() {
95 $browserStrings = array(
96 'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
97 'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)',
98 'Mozilla/4.0 (compatible; MSIE 6.01; Windows NT 6.0)',
99 'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
100 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
101 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4325)',
102 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)',
103 'Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)',
104 'Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)',
105 'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)',
106 'Mozilla/4.0 (X11; MSIE 6.0; i686; .NET CLR 1.1.4322; .NET CLR 2.0.50727; FDM)',
107 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 6.0)',
108 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.2)',
109 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.0)',
110 'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
111 'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)',
112 'Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)',
113 'Mozilla/4.0 (compatible;MSIE 6.0;Windows 98;Q312461)',
114 '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)',
115 'Mozilla/4.0 (compatible; U; MSIE 6.0; Windows NT 5.1)',
116 'Mozilla/4.0 (compatible; MSIE 6,0; Windows NT 5,1; SV1; Alexa Toolbar)'
117 );
118 $expectedMembers = array(
119 'browser' => 'msie',
120 'version' => '6'
121 );
122 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
123 }
124
125 /**
126 * @test
127 */
128 public function checkBrowserInfoIE7() {
129 $browserStrings = array(
130 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
131 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; el-GR)',
132 '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)',
133 '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)',
134 '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)',
135 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; fr-FR)',
136 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; en-US)',
137 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; .NET CLR 2.0.50727)',
138 '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)',
139 'Mozilla/4.0 (Windows; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
140 'Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1; .NET CLR 3.0.04506.30)',
141 'Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1)',
142 'Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)',
143 '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)',
144 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)',
145 '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)',
146 '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)',
147 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; Media Center PC 5.0; .NET CLR 2.0.50727)',
148 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 3.0.04506)',
149 '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)'
150 );
151 $expectedMembers = array(
152 'browser' => 'msie',
153 'version' => '7'
154 );
155 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
156 }
157
158 /**
159 * @test
160 */
161 public function checkBrowserInfoIE8() {
162 $browserStrings = array(
163 '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)',
164 '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)',
165 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)',
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; Zune 3.0)',
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; msn OptimizedIE8;ZHCN)',
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; MS-RTC LM 8)',
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; InfoPath.3; Zune 4.0)',
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; InfoPath.3)',
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; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; yie8)',
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; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; Zune 3.0; MS-RTC LM 8)',
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; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; Zune 4.0)',
174 '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)',
175 '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)',
176 '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)',
177 '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)',
178 '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)',
179 '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)',
180 '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)',
181 '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)',
182 '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)',
183 '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)',
184 );
185 $expectedMembers = array(
186 'browser' => 'msie',
187 'version' => '8'
188 );
189 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
190 }
191
192 /**
193 * @test
194 */
195 public function checkGeckoVersion() {
196 $userAgentString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3';
197 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
198
199 $this->assertEquals(
200 '1.9.2.3',
201 $infoArray['all']['gecko']
202 );
203 }
204
205 /**
206 * @test
207 */
208 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows7() {
209 $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)';
210 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
211
212 $this->assertContains(
213 'win7',
214 $infoArray['all_systems']
215 );
216 // Check for backwards compatibility (deprecated since 4.5)
217 $this->assertEquals(
218 'winNT',
219 $infoArray['system']
220 );
221 }
222
223 /**
224 * @test
225 */
226 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() {
227 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)';
228 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
229
230 $this->assertContains(
231 'winVista',
232 $infoArray['all_systems']
233 );
234 // Check for backwards compatibility (deprecated since 4.5)
235 $this->assertSame(
236 'winNT',
237 $infoArray['system']
238 );
239 }
240
241 /**
242 * @test
243 */
244 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() {
245 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
246 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
247
248 $this->assertContains(
249 'winXP',
250 $infoArray['all_systems']
251 );
252 // Check for backwards compatibility (deprecated since 4.5)
253 $this->assertSame(
254 'winNT',
255 $infoArray['system']
256 );
257 }
258
259 /**
260 * @test
261 */
262 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() {
263 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
264 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
265
266 $this->assertContains(
267 'win2k',
268 $infoArray['all_systems']
269 );
270 // Check for backwards compatibility (deprecated since 4.5)
271 $this->assertSame(
272 'winNT',
273 $infoArray['system']
274 );
275 }
276
277 /**
278 * @test
279 */
280 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() {
281 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
282 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
283
284 $this->assertContains(
285 'win2k',
286 $infoArray['all_systems']
287 );
288 // Check for backwards compatibility (deprecated since 4.5)
289 $this->assertSame(
290 'winNT',
291 $infoArray['system']
292 );
293 }
294
295 /**
296 * @test
297 */
298 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() {
299 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)';
300 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
301
302 $this->assertSame(
303 'winNT',
304 $infoArray['system']
305 );
306 }
307
308 /**
309 * @test
310 */
311 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringContainingNtAsFallback() {
312 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)';
313 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
314
315 $this->assertSame(
316 'winNT',
317 $infoArray['system']
318 );
319 }
320
321 /**
322 * @test
323 */
324 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() {
325 $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';
326 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
327
328 $this->assertContains(
329 'iOS',
330 $infoArray['all_systems']
331 );
332 // Check for backwards compatibility (deprecated since 4.5)
333 $this->assertSame(
334 'mac',
335 $infoArray['system']
336 );
337 }
338
339 /**
340 * @test
341 */
342 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() {
343 $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';
344 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
345
346 $this->assertContains(
347 'iOS',
348 $infoArray['all_systems']
349 );
350 // Check for backwards compatibility (deprecated since 4.5)
351 $this->assertSame(
352 'mac',
353 $infoArray['system']
354 );
355 }
356
357 /**
358 * @test
359 */
360 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() {
361 $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';
362 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
363
364 $this->assertContains(
365 'iOS',
366 $infoArray['all_systems']
367 );
368 // Check for backwards compatibility (deprecated since 4.5)
369 $this->assertSame(
370 'mac',
371 $infoArray['system']
372 );
373 }
374
375 /**
376 * @test
377 */
378 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() {
379 $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';
380 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
381
382 $this->assertSame(
383 'mac',
384 $infoArray['system']
385 );
386 }
387
388 /**
389 * @test
390 */
391 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() {
392 $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';
393 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
394
395 $this->assertSame(
396 'linux',
397 $infoArray['system']
398 );
399 }
400
401 /**
402 * @test
403 */
404 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() {
405 $userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9';
406 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
407
408 $this->assertSame(
409 'unix_sun',
410 $infoArray['system']
411 );
412 }
413
414 /**
415 * Provide various user agent strings for android devices
416 *
417 * @static
418 * @return array List of user agents
419 */
420 public static function androidUserAgentsProvider() {
421 $agents = array(
422 'defaultBrowser' => array(
423 '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',
424 ),
425 'operaMini' => array(
426 'agent' => 'Opera/9.80 (Android; Opera Mini/6.0.24556/24.816; U; en) Presto/2.5.25 Version/10.54'
427 )
428 );
429 return $agents;
430 }
431
432 /**
433 * @test
434 * @dataProvider androidUserAgentsProvider
435 */
436 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid($userAgentString) {
437 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
438
439 $this->assertContains(
440 'android',
441 $infoArray['all_systems']
442 );
443 // Check for backwards compatibility (deprecated since 4.5)
444 $this->assertSame(
445 'linux',
446 $infoArray['system']
447 );
448 }
449
450 /**
451 * @test
452 */
453 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfOpenbsd() {
454 $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)';
455 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
456
457 $this->assertContains(
458 'unix_bsd',
459 $infoArray['all_systems']
460 );
461 }
462
463 /**
464 * @test
465 */
466 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfNetbsd() {
467 $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)';
468 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
469
470 $this->assertContains(
471 'unix_bsd',
472 $infoArray['all_systems']
473 );
474 }
475
476 /**
477 * @test
478 */
479 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfFreebsd() {
480 $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2';
481 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
482
483 $this->assertContains(
484 'unix_bsd',
485 $infoArray['all_systems']
486 );
487 }
488
489 /**
490 * @test
491 */
492 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfChromeOs() {
493 $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';
494 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
495
496 $this->assertContains(
497 'chrome',
498 $infoArray['all_systems']
499 );
500 }
501
502 /**
503 * @test
504 */
505 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfSafari() {
506 $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';
507 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
508
509 $this->assertSame(
510 'safari',
511 $infoArray['browser']
512 );
513 }
514
515 /**
516 * @test
517 */
518 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfFirefox() {
519 $userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8';
520 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
521
522 $this->assertSame(
523 'firefox',
524 $infoArray['browser']
525 );
526 }
527
528 /**
529 * @test
530 */
531 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfOpera() {
532 $userAgentString = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE amd64; U; en) Presto/2.2.15 Version/10.10';
533 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
534
535 $this->assertSame(
536 'opera',
537 $infoArray['browser']
538 );
539 }
540
541 /**
542 * @test
543 */
544 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnAndroid() {
545 $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';
546 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
547
548 $this->assertSame(
549 'safari',
550 $infoArray['browser']
551 );
552 }
553
554 /**
555 * @test
556 */
557 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnIphone() {
558 $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';
559 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
560
561 $this->assertSame(
562 'safari',
563 $infoArray['browser']
564 );
565 }
566
567 /**
568 * @test
569 */
570 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfKonqueror() {
571 $userAgentString = 'Mozilla/5.0 (compatible; Konqueror/4.4; FreeBSD) KHTML/4.4.5 (like Gecko)';
572 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
573
574 $this->assertSame(
575 'konqueror',
576 $infoArray['browser']
577 );
578 }
579 }
580 ?>