[BUGFIX] ClientUtility does not detect Internet Explorer 11
[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 $actual = $expected = array();
69 foreach ($browserStrings as $browserString) {
70 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($browserString);
71 $expected[] = $expectedMembers;
72 $actual[] = array(
73 'browser' => $infoArray['browser'],
74 'version' => array_shift(explode('.', $infoArray['version']))
75 );
76 }
77 $this->assertSame($expected, $actual);
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 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)',
143 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)',
144 );
145 $expectedMembers = array(
146 'browser' => 'msie',
147 'version' => '7'
148 );
149 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
150 }
151
152 /**
153 * @test
154 */
155 public function checkBrowserInfoIE8() {
156 $browserStrings = array(
157 '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)',
158 '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)',
159 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)',
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; Zune 3.0)',
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; msn OptimizedIE8;ZHCN)',
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; MS-RTC LM 8)',
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.3; Zune 4.0)',
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.3)',
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.4; OfficeLivePatch.1.3; yie8)',
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; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; Zune 3.0; 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; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; Zune 4.0)',
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; 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.2; FDM; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 1.1.4322)',
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.2; .NET4.0C; .NET4.0E; FDM)',
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 4.0.20402; MS-RTC LM 8)',
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; .NET CLR 1.1.4322; InfoPath.2; 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; .NET CLR 1.1.4322; InfoPath.2)',
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; InfoPath.3; .NET CLR 4.0.20506)',
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)',
176 '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)',
177 '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)'
178 );
179 $expectedMembers = array(
180 'browser' => 'msie',
181 'version' => '8'
182 );
183 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
184 }
185
186 /**
187 * @test
188 */
189 public function checkBrowserInfoIE9() {
190 $browserStrings = array(
191 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
192 );
193 $expectedMembers = array(
194 'browser' => 'msie',
195 'version' => '9'
196 );
197 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
198 }
199
200 /**
201 * @test
202 */
203 public function checkBrowserInfoIE10() {
204 $browserStrings = array(
205 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)',
206 );
207 $expectedMembers = array(
208 'browser' => 'msie',
209 'version' => '10'
210 );
211 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
212 }
213
214 /**
215 * @test
216 */
217 public function checkBrowserInfoIE11() {
218 $browserStrings = array(
219 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko',
220 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko',
221 );
222 $expectedMembers = array(
223 'browser' => 'msie',
224 'version' => '11'
225 );
226 $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
227 }
228
229 /**
230 * @test
231 */
232 public function checkGeckoVersion() {
233 $userAgentString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3';
234 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
235 $this->assertEquals('1.9.2.3', $infoArray['all']['gecko']);
236 }
237
238 /**
239 * @test
240 */
241 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows8() {
242 $userAgentString = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';
243 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
244 $this->assertContains('win8', $infoArray['all_systems']);
245 }
246
247
248 /**
249 * @test
250 */
251 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows8rev1() {
252 $userAgentString = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.3; Trident/6.0)';
253 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
254 $this->assertContains('win8', $infoArray['all_systems']);
255 }
256
257 /**
258 * @test
259 */
260 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows7() {
261 $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)';
262 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
263 $this->assertContains('win7', $infoArray['all_systems']);
264 }
265
266 /**
267 * @test
268 */
269 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() {
270 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)';
271 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
272 $this->assertContains('winVista', $infoArray['all_systems']);
273 }
274
275 /**
276 * @test
277 */
278 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() {
279 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
280 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
281 $this->assertContains('winXP', $infoArray['all_systems']);
282 }
283
284 /**
285 * @test
286 */
287 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() {
288 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
289 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
290 $this->assertContains('win2k', $infoArray['all_systems']);
291 }
292
293 /**
294 * @test
295 */
296 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() {
297 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
298 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
299 $this->assertContains('win2k', $infoArray['all_systems']);
300 }
301
302 /**
303 * @test
304 */
305 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() {
306 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)';
307 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
308 $this->assertContains('winNT', $infoArray['all_systems']);
309 }
310
311 /**
312 * @test
313 */
314 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() {
315 $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';
316 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
317 $this->assertContains('iOS', $infoArray['all_systems']);
318 }
319
320 /**
321 * @test
322 */
323 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() {
324 $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';
325 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
326 $this->assertContains('iOS', $infoArray['all_systems']);
327 }
328
329 /**
330 * @test
331 */
332 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() {
333 $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';
334 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
335 $this->assertContains('iOS', $infoArray['all_systems']);
336 }
337
338 /**
339 * @test
340 */
341 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() {
342 $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';
343 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
344 $this->assertContains('mac', $infoArray['all_systems']);
345 }
346
347 /**
348 * @test
349 */
350 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() {
351 $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';
352 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
353 $this->assertContains('linux', $infoArray['all_systems']);
354 }
355
356 /**
357 * @test
358 */
359 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() {
360 $userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9';
361 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
362 $this->assertContains('unix_sun', $infoArray['all_systems']);
363 }
364
365 /**
366 * Provide various user agent strings for android devices
367 *
368 * @static
369 * @return array List of user agents
370 */
371 static public function androidUserAgentsProvider() {
372 $agents = array(
373 'defaultBrowser' => array(
374 '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'
375 ),
376 'operaMini' => array(
377 'agent' => 'Opera/9.80 (Android; Opera Mini/6.0.24556/24.816; U; en) Presto/2.5.25 Version/10.54'
378 )
379 );
380 return $agents;
381 }
382
383 /**
384 * @test
385 * @dataProvider androidUserAgentsProvider
386 */
387 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid($userAgentString) {
388 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
389 $this->assertContains('android', $infoArray['all_systems']);
390 }
391
392 /**
393 * @test
394 */
395 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfOpenbsd() {
396 $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)';
397 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
398 $this->assertContains('unix_bsd', $infoArray['all_systems']);
399 }
400
401 /**
402 * @test
403 */
404 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfNetbsd() {
405 $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)';
406 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
407 $this->assertContains('unix_bsd', $infoArray['all_systems']);
408 }
409
410 /**
411 * @test
412 */
413 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfFreebsd() {
414 $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2';
415 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
416 $this->assertContains('unix_bsd', $infoArray['all_systems']);
417 }
418
419 /**
420 * @test
421 */
422 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfChromeOs() {
423 $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';
424 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
425 $this->assertContains('chrome', $infoArray['all_systems']);
426 }
427
428 /**
429 * @test
430 */
431 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfSafari() {
432 $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';
433 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
434 $this->assertSame('safari', $infoArray['browser']);
435 }
436
437 /**
438 * @test
439 */
440 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfFirefox() {
441 $userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8';
442 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
443 $this->assertSame('firefox', $infoArray['browser']);
444 }
445
446 /**
447 * @test
448 */
449 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfOpera() {
450 $userAgentString = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE amd64; U; en) Presto/2.2.15 Version/10.10';
451 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
452 $this->assertSame('opera', $infoArray['browser']);
453 }
454
455 /**
456 * @test
457 */
458 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnAndroid() {
459 $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';
460 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
461 $this->assertSame('safari', $infoArray['browser']);
462 }
463
464 /**
465 * @test
466 */
467 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnIphone() {
468 $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';
469 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
470 $this->assertSame('safari', $infoArray['browser']);
471 }
472
473 /**
474 * @test
475 */
476 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfKonqueror() {
477 $userAgentString = 'Mozilla/5.0 (compatible; Konqueror/4.4; FreeBSD) KHTML/4.4.5 (like Gecko)';
478 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
479 $this->assertSame('konqueror', $infoArray['browser']);
480 }
481
482 }