TYPO3 API  SVNRelease
t3lib_utility_clientTest.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 * Copyright notice
00004 *
00005 * (c) 2010-2011 Steffen Kamper (info@sk-typo3.de)
00006 * All rights reserved
00007 *
00008 * This script is part of the TYPO3 project. The TYPO3 project is
00009 * free software; you can redistribute it and/or modify
00010 * it under the terms of the GNU General Public License as published by
00011 * the Free Software Foundation; either version 2 of the License, or
00012 * (at your option) any later version.
00013 *
00014 * The GNU General Public License can be found at
00015 * http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 * This script is distributed in the hope that it will be useful,
00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 * GNU General Public License for more details.
00021 *
00022 * This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 /**
00026  * Testcase for the t3lib_utility_Client class.
00027  *
00028  * @package TYPO3
00029  * @subpackage t3lib
00030  *
00031  * @author Steffen Kamper <info@sk-typo3.de>
00032  */
00033 class t3lib_utility_clientTest extends tx_phpunit_testcase {
00034     /**
00035      * backed-up TYPO3_CONF_VARS SC_OPTIONS
00036      *
00037      * @var array
00038      */
00039     private $scOptionsBackup = array();
00040 
00041     /**
00042      * backed-up T3_VAR callUserFunction
00043      *
00044      * @var array
00045      */
00046     private $callUserFunctionBackup = array();
00047 
00048     public function setUp() {
00049         $this->scOptionsBackup = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'];
00050         $this->callUserFunctionBackup = $GLOBALS['T3_VAR']['callUserFunction'];
00051     }
00052 
00053     public function tearDown() {
00054         $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = $this->scOptionsBackup;
00055         $GLOBALS['T3_VAR']['callUserFunction'] = $this->callUserFunctionBackup;
00056     }
00057 
00058 
00059     //////////////////////////////////////////////////////////
00060     // Utility Functions
00061     //////////////////////////////////////////////////////////
00062 
00063 
00064     /**
00065      * Compares array of UA strings with expected result array of browser/version pair
00066      *
00067      * @param array $browserStrings array with userAgent strings
00068      * @param array $expectedMembers array with expected browser/version for given userAgent strings
00069      */
00070     private function analyzeUserAgentStrings($browserStrings, $expectedMembers) {
00071         $compare = $expected = array();
00072         foreach ($browserStrings as $browserString) {
00073             $infoArray = t3lib_utility_Client::getBrowserInfo($browserString);
00074             $expected[] = $expectedMembers;
00075             $compare[] = array(
00076                 'browser' => $infoArray['browser'],
00077                 'version' => substr($infoArray['version'], 0, 1)
00078             );
00079         }
00080         $this->assertEquals(
00081             $expected,
00082             $compare
00083         );
00084     }
00085 
00086 
00087     //////////////////////////////////////////////////////////
00088     // Tests concerning t3lib_utility_Client::getBrowserInfo
00089     //////////////////////////////////////////////////////////
00090 
00091     /**
00092      * @test
00093      */
00094     public function checkBrowserInfoIE6() {
00095         $browserStrings = array(
00096             'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
00097             'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)',
00098             'Mozilla/4.0 (compatible; MSIE 6.01; Windows NT 6.0)',
00099             'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
00100             'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
00101             'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4325)',
00102             'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)',
00103             'Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)',
00104             'Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)',
00105             'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)',
00106             'Mozilla/4.0 (X11; MSIE 6.0; i686; .NET CLR 1.1.4322; .NET CLR 2.0.50727; FDM)',
00107             'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 6.0)',
00108             'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.2)',
00109             'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.0)',
00110             'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
00111             'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)',
00112             'Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)',
00113             'Mozilla/4.0 (compatible;MSIE 6.0;Windows 98;Q312461)',
00114             '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)',
00115             'Mozilla/4.0 (compatible; U; MSIE 6.0; Windows NT 5.1)',
00116             'Mozilla/4.0 (compatible; MSIE 6,0; Windows NT 5,1; SV1; Alexa Toolbar)'
00117         );
00118         $expectedMembers = array(
00119             'browser' => 'msie',
00120             'version' => '6'
00121         );
00122         $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
00123     }
00124 
00125     /**
00126      * @test
00127      */
00128     public function checkBrowserInfoIE7() {
00129         $browserStrings = array(
00130             'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
00131             'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; el-GR)',
00132             '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)',
00133             '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)',
00134             '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)',
00135             'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; fr-FR)',
00136             'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; en-US)',
00137             'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; .NET CLR 2.0.50727)',
00138             '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)',
00139             'Mozilla/4.0 (Windows; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
00140             'Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1; .NET CLR 3.0.04506.30)',
00141             'Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1)',
00142             'Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)',
00143             '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)',
00144             'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)',
00145             '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)',
00146             '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)',
00147             'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; Media Center PC 5.0; .NET CLR 2.0.50727)',
00148             'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 3.0.04506)',
00149             '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)'
00150         );
00151         $expectedMembers = array(
00152             'browser' => 'msie',
00153             'version' => '7'
00154         );
00155         $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
00156     }
00157 
00158     /**
00159      * @test
00160      */
00161     public function checkBrowserInfoIE8() {
00162         $browserStrings = array(
00163             '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)',
00164             '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)',
00165             'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)',
00166             '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)',
00167             '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)',
00168             '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)',
00169             '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)',
00170             '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)',
00171             '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)',
00172             '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)',
00173             '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)',
00174             '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)',
00175             '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)',
00176             '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)',
00177             '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)',
00178             '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)',
00179             '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)',
00180             '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)',
00181             '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)',
00182             '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)',
00183             '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)',
00184         );
00185         $expectedMembers = array(
00186             'browser' => 'msie',
00187             'version' => '8'
00188         );
00189         $this->analyzeUserAgentStrings($browserStrings, $expectedMembers);
00190     }
00191 
00192     /**
00193      * @test
00194      */
00195     public function checkGeckoVersion() {
00196         $userAgentString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3';
00197         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00198 
00199         $this->assertEquals(
00200             '1.9.2.3',
00201             $infoArray['all']['gecko']
00202         );
00203     }
00204 
00205     /**
00206      * @test
00207      */
00208     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows7() {
00209         $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)';
00210         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00211 
00212         $this->assertContains(
00213             'win7',
00214             $infoArray['all_systems']
00215         );
00216             // Check for backwards compatibility (deprecated since 4.5)
00217         $this->assertEquals(
00218             'winNT',
00219             $infoArray['system']
00220         );
00221     }
00222 
00223     /**
00224      * @test
00225      */
00226     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() {
00227         $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)';
00228         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00229 
00230         $this->assertContains(
00231             'winVista',
00232             $infoArray['all_systems']
00233         );
00234             // Check for backwards compatibility (deprecated since 4.5)
00235         $this->assertSame(
00236             'winNT',
00237             $infoArray['system']
00238         );
00239     }
00240 
00241     /**
00242      * @test
00243      */
00244     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() {
00245         $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
00246         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00247 
00248         $this->assertContains(
00249             'winXP',
00250             $infoArray['all_systems']
00251         );
00252             // Check for backwards compatibility (deprecated since 4.5)
00253         $this->assertSame(
00254             'winNT',
00255             $infoArray['system']
00256         );
00257     }
00258 
00259     /**
00260      * @test
00261      */
00262     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() {
00263         $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
00264         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00265 
00266         $this->assertContains(
00267             'win2k',
00268             $infoArray['all_systems']
00269         );
00270             // Check for backwards compatibility (deprecated since 4.5)
00271         $this->assertSame(
00272             'winNT',
00273             $infoArray['system']
00274         );
00275     }
00276 
00277     /**
00278      * @test
00279      */
00280     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() {
00281         $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
00282         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00283 
00284         $this->assertContains(
00285             'win2k',
00286             $infoArray['all_systems']
00287         );
00288             // Check for backwards compatibility (deprecated since 4.5)
00289         $this->assertSame(
00290             'winNT',
00291             $infoArray['system']
00292         );
00293     }
00294 
00295     /**
00296      * @test
00297      */
00298     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() {
00299         $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)';
00300         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00301 
00302         $this->assertSame(
00303             'winNT',
00304             $infoArray['system']
00305         );
00306     }
00307 
00308     /**
00309      * @test
00310      */
00311     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringContainingNtAsFallback() {
00312         $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)';
00313         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00314 
00315         $this->assertSame(
00316             'winNT',
00317             $infoArray['system']
00318         );
00319     }
00320 
00321     /**
00322      * @test
00323      */
00324     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() {
00325         $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';
00326         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00327 
00328         $this->assertContains(
00329             'iOS',
00330             $infoArray['all_systems']
00331         );
00332             // Check for backwards compatibility (deprecated since 4.5)
00333         $this->assertSame(
00334             'mac',
00335             $infoArray['system']
00336         );
00337     }
00338 
00339     /**
00340      * @test
00341      */
00342     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() {
00343         $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';
00344         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00345 
00346         $this->assertContains(
00347             'iOS',
00348             $infoArray['all_systems']
00349         );
00350             // Check for backwards compatibility (deprecated since 4.5)
00351         $this->assertSame(
00352             'mac',
00353             $infoArray['system']
00354         );
00355     }
00356 
00357     /**
00358      * @test
00359      */
00360     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() {
00361         $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';
00362         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00363 
00364         $this->assertContains(
00365             'iOS',
00366             $infoArray['all_systems']
00367         );
00368             // Check for backwards compatibility (deprecated since 4.5)
00369         $this->assertSame(
00370             'mac',
00371             $infoArray['system']
00372         );
00373     }
00374 
00375     /**
00376      * @test
00377      */
00378     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() {
00379         $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';
00380         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00381 
00382         $this->assertSame(
00383             'mac',
00384             $infoArray['system']
00385         );
00386     }
00387 
00388     /**
00389      * @test
00390      */
00391     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() {
00392         $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';
00393         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00394 
00395         $this->assertSame(
00396             'linux',
00397             $infoArray['system']
00398         );
00399     }
00400 
00401     /**
00402      * @test
00403      */
00404     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() {
00405         $userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9';
00406         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00407 
00408         $this->assertSame(
00409             'unix_sun',
00410             $infoArray['system']
00411         );
00412     }
00413 
00414     /**
00415      * @test
00416      */
00417     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid() {
00418         $userAgentString = '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';
00419         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00420 
00421         $this->assertContains(
00422             'android',
00423             $infoArray['all_systems']
00424         );
00425             // Check for backwards compatibility (deprecated since 4.5)
00426         $this->assertSame(
00427             'linux',
00428             $infoArray['system']
00429         );
00430     }
00431 
00432     /**
00433      * @test
00434      */
00435     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfOpenbsd() {
00436         $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)';
00437         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00438 
00439         $this->assertContains(
00440             'unix_bsd',
00441             $infoArray['all_systems']
00442         );
00443     }
00444 
00445     /**
00446      * @test
00447      */
00448     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfNetbsd() {
00449         $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)';
00450         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00451 
00452         $this->assertContains(
00453             'unix_bsd',
00454             $infoArray['all_systems']
00455         );
00456     }
00457 
00458     /**
00459      * @test
00460      */
00461     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfFreebsd() {
00462         $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2';
00463         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00464 
00465         $this->assertContains(
00466             'unix_bsd',
00467             $infoArray['all_systems']
00468         );
00469     }
00470 
00471     /**
00472      * @test
00473      */
00474     public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfChromeOs() {
00475         $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';
00476         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00477 
00478         $this->assertContains(
00479             'chrome',
00480             $infoArray['all_systems']
00481         );
00482     }
00483     
00484     /**
00485      * @test
00486      */
00487     public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfSafari() {
00488         $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';
00489         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00490 
00491         $this->assertSame(
00492             'safari',
00493             $infoArray['browser']
00494         );
00495     }
00496 
00497     /**
00498      * @test
00499      */
00500     public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfFirefox() {
00501         $userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8';
00502         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00503 
00504         $this->assertSame(
00505             'firefox',
00506             $infoArray['browser']
00507         );
00508     }
00509 
00510     /**
00511      * @test
00512      */
00513     public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfOpera() {
00514         $userAgentString = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE amd64; U; en) Presto/2.2.15 Version/10.10';
00515         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00516 
00517         $this->assertSame(
00518             'opera',
00519             $infoArray['browser']
00520         );
00521     }
00522     
00523     /**
00524      * @test
00525      */
00526     public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnAndroid() {
00527         $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';
00528         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00529 
00530         $this->assertSame(
00531             'safari',
00532             $infoArray['browser']
00533         );
00534     }
00535 
00536     /**
00537      * @test
00538      */
00539     public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfMobileSafariOnIphone() {
00540         $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';
00541         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00542 
00543         $this->assertSame(
00544             'safari',
00545             $infoArray['browser']
00546         );
00547     }
00548 
00549     /**
00550      * @test
00551      */
00552     public function getBrowserInfoReturnsCorrectBrowserValueForUserAgentStringOfKonqueror() {
00553         $userAgentString = 'Mozilla/5.0 (compatible; Konqueror/4.4; FreeBSD) KHTML/4.4.5 (like Gecko)';
00554         $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
00555 
00556         $this->assertSame(
00557             'konqueror',
00558             $infoArray['browser']
00559         );
00560     }
00561 }
00562 ?>