[TASK] Replace Space Indent into Tab indent (CGL Cleanup)
[Packages/TYPO3.CMS.git] / tests / Unit / 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 }
217
218 /**
219 * @test
220 */
221 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() {
222 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)';
223 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
224
225 $this->assertContains(
226 'winVista',
227 $infoArray['all_systems']
228 );
229 }
230
231 /**
232 * @test
233 */
234 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() {
235 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
236 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
237
238 $this->assertContains(
239 'winXP',
240 $infoArray['all_systems']
241 );
242 }
243
244 /**
245 * @test
246 */
247 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() {
248 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
249 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
250
251 $this->assertContains(
252 'win2k',
253 $infoArray['all_systems']
254 );
255 }
256
257 /**
258 * @test
259 */
260 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() {
261 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
262 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
263
264 $this->assertContains(
265 'win2k',
266 $infoArray['all_systems']
267 );
268 }
269
270 /**
271 * @test
272 */
273 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() {
274 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)';
275 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
276
277 $this->assertContains(
278 'winNT',
279 $infoArray['all_systems']
280 );
281 }
282
283 /**
284 * @test
285 */
286 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() {
287 $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';
288 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
289
290 $this->assertContains(
291 'iOS',
292 $infoArray['all_systems']
293 );
294 }
295
296 /**
297 * @test
298 */
299 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() {
300 $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';
301 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
302
303 $this->assertContains(
304 'iOS',
305 $infoArray['all_systems']
306 );
307 }
308
309 /**
310 * @test
311 */
312 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() {
313 $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';
314 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
315
316 $this->assertContains(
317 'iOS',
318 $infoArray['all_systems']
319 );
320 }
321
322 /**
323 * @test
324 */
325 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() {
326 $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';
327 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
328
329 $this->assertContains(
330 'mac',
331 $infoArray['all_systems']
332 );
333 }
334
335 /**
336 * @test
337 */
338 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() {
339 $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';
340 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
341
342 $this->assertContains(
343 'linux',
344 $infoArray['all_systems']
345 );
346 }
347
348 /**
349 * @test
350 */
351 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() {
352 $userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9';
353 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
354
355 $this->assertContains(
356 'unix_sun',
357 $infoArray['all_systems']
358 );
359 }
360
361 /**
362 * Provide various user agent strings for android devices
363 *
364 * @static
365 * @return array List of user agents
366 */
367 public static function androidUserAgentsProvider() {
368 $agents = array(
369 'defaultBrowser' => array(
370 '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',
371 ),
372 'operaMini' => array(
373 'agent' => 'Opera/9.80 (Android; Opera Mini/6.0.24556/24.816; U; en) Presto/2.5.25 Version/10.54'
374 )
375 );
376 return $agents;
377 }
378
379 /**
380 * @test
381 * @dataProvider androidUserAgentsProvider
382 */
383 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid($userAgentString) {
384 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
385
386 $this->assertContains(
387 'android',
388 $infoArray['all_systems']
389 );
390 }
391
392 /**
393 * @test
394 */
395 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfOpenbsd() {
396 $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)';
397 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
398
399 $this->assertContains(
400 'unix_bsd',
401 $infoArray['all_systems']
402 );
403 }
404
405 /**
406 * @test
407 */
408 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfNetbsd() {
409 $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)';
410 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
411
412 $this->assertContains(
413 'unix_bsd',
414 $infoArray['all_systems']
415 );
416 }
417
418 /**
419 * @test
420 */
421 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfFreebsd() {
422 $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2';
423 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
424
425 $this->assertContains(
426 'unix_bsd',
427 $infoArray['all_systems']
428 );
429 }
430
431 /**
432 * @test
433 */
434 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfChromeOs() {
435 $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';
436 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
437
438 $this->assertContains(
439 'chrome',
440 $infoArray['all_systems']
441 );
442 }
443
444 /**
445 * @test
446 */
447 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfSafari() {
448 $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';
449 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
450
451 $this->assertSame(
452 'safari',
453 $infoArray['browser']
454 );
455 }
456
457 /**
458 * @test
459 */
460 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfFirefox() {
461 $userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8';
462 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
463
464 $this->assertSame(
465 'firefox',
466 $infoArray['browser']
467 );
468 }
469
470 /**
471 * @test
472 */
473 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfOpera() {
474 $userAgentString = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE amd64; U; en) Presto/2.2.15 Version/10.10';
475 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
476
477 $this->assertSame(
478 'opera',
479 $infoArray['browser']
480 );
481 }
482
483 /**
484 * @test
485 */
486 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnAndroid() {
487 $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';
488 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
489
490 $this->assertSame(
491 'safari',
492 $infoArray['browser']
493 );
494 }
495
496 /**
497 * @test
498 */
499 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnIphone() {
500 $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';
501 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
502
503 $this->assertSame(
504 'safari',
505 $infoArray['browser']
506 );
507 }
508
509 /**
510 * @test
511 */
512 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfKonqueror() {
513 $userAgentString = 'Mozilla/5.0 (compatible; Konqueror/4.4; FreeBSD) KHTML/4.4.5 (like Gecko)';
514 $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
515
516 $this->assertSame(
517 'konqueror',
518 $infoArray['browser']
519 );
520 }
521 }
522 ?>