[TASK] TypoScript: Condition for Windows 8
[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 getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows8() {
197 $userAgentString = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';
198 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
199 $this->assertContains('win8', $infoArray['all_systems']);
200 }
201
202
203 /**
204 * @test
205 */
206 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows8rev1() {
207 $userAgentString = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.3; Trident/6.0)';
208 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
209 $this->assertContains('win8', $infoArray['all_systems']);
210 }
211
212 /**
213 * @test
214 */
215 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows7() {
216 $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)';
217 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
218 $this->assertContains('win7', $infoArray['all_systems']);
219 }
220
221 /**
222 * @test
223 */
224 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() {
225 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)';
226 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
227 $this->assertContains('winVista', $infoArray['all_systems']);
228 }
229
230 /**
231 * @test
232 */
233 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() {
234 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
235 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
236 $this->assertContains('winXP', $infoArray['all_systems']);
237 }
238
239 /**
240 * @test
241 */
242 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() {
243 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
244 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
245 $this->assertContains('win2k', $infoArray['all_systems']);
246 }
247
248 /**
249 * @test
250 */
251 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() {
252 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
253 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
254 $this->assertContains('win2k', $infoArray['all_systems']);
255 }
256
257 /**
258 * @test
259 */
260 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() {
261 $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)';
262 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
263 $this->assertContains('winNT', $infoArray['all_systems']);
264 }
265
266 /**
267 * @test
268 */
269 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() {
270 $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';
271 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
272 $this->assertContains('iOS', $infoArray['all_systems']);
273 }
274
275 /**
276 * @test
277 */
278 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() {
279 $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';
280 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
281 $this->assertContains('iOS', $infoArray['all_systems']);
282 }
283
284 /**
285 * @test
286 */
287 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() {
288 $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';
289 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
290 $this->assertContains('iOS', $infoArray['all_systems']);
291 }
292
293 /**
294 * @test
295 */
296 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() {
297 $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';
298 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
299 $this->assertContains('mac', $infoArray['all_systems']);
300 }
301
302 /**
303 * @test
304 */
305 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() {
306 $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';
307 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
308 $this->assertContains('linux', $infoArray['all_systems']);
309 }
310
311 /**
312 * @test
313 */
314 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() {
315 $userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9';
316 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
317 $this->assertContains('unix_sun', $infoArray['all_systems']);
318 }
319
320 /**
321 * Provide various user agent strings for android devices
322 *
323 * @static
324 * @return array List of user agents
325 */
326 static public function androidUserAgentsProvider() {
327 $agents = array(
328 'defaultBrowser' => array(
329 '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'
330 ),
331 'operaMini' => array(
332 'agent' => 'Opera/9.80 (Android; Opera Mini/6.0.24556/24.816; U; en) Presto/2.5.25 Version/10.54'
333 )
334 );
335 return $agents;
336 }
337
338 /**
339 * @test
340 * @dataProvider androidUserAgentsProvider
341 */
342 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid($userAgentString) {
343 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
344 $this->assertContains('android', $infoArray['all_systems']);
345 }
346
347 /**
348 * @test
349 */
350 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfOpenbsd() {
351 $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)';
352 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
353 $this->assertContains('unix_bsd', $infoArray['all_systems']);
354 }
355
356 /**
357 * @test
358 */
359 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfNetbsd() {
360 $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)';
361 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
362 $this->assertContains('unix_bsd', $infoArray['all_systems']);
363 }
364
365 /**
366 * @test
367 */
368 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfFreebsd() {
369 $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2';
370 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
371 $this->assertContains('unix_bsd', $infoArray['all_systems']);
372 }
373
374 /**
375 * @test
376 */
377 public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfChromeOs() {
378 $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';
379 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
380 $this->assertContains('chrome', $infoArray['all_systems']);
381 }
382
383 /**
384 * @test
385 */
386 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfSafari() {
387 $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';
388 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
389 $this->assertSame('safari', $infoArray['browser']);
390 }
391
392 /**
393 * @test
394 */
395 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfFirefox() {
396 $userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8';
397 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
398 $this->assertSame('firefox', $infoArray['browser']);
399 }
400
401 /**
402 * @test
403 */
404 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfOpera() {
405 $userAgentString = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE amd64; U; en) Presto/2.2.15 Version/10.10';
406 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
407 $this->assertSame('opera', $infoArray['browser']);
408 }
409
410 /**
411 * @test
412 */
413 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnAndroid() {
414 $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';
415 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
416 $this->assertSame('safari', $infoArray['browser']);
417 }
418
419 /**
420 * @test
421 */
422 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnIphone() {
423 $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';
424 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
425 $this->assertSame('safari', $infoArray['browser']);
426 }
427
428 /**
429 * @test
430 */
431 public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfKonqueror() {
432 $userAgentString = 'Mozilla/5.0 (compatible; Konqueror/4.4; FreeBSD) KHTML/4.4.5 (like Gecko)';
433 $infoArray = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgentString);
434 $this->assertSame('konqueror', $infoArray['browser']);
435 }
436
437 }