assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '7.0', $browser->getVersion() ); //Use Trident Version $browser = new Browser( 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '7.0', $browser->getVersion() ); //Use Trident Version $browser = new Browser( 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; LEN2)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '9.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '11.0', $browser->getVersion() ); //Use Trident Version $browser = new Browser( 'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '6.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '6.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '7.0', $browser->getVersion() ); $browser = new Browser( '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)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '7.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '8.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '8.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '9.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '9.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '10.0', $browser->getVersion() ); $browser = new Browser( 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)' ); $this->assertEquals( Browser::BROWSER_IE, $browser->getBrowser() ); $this->assertEquals( '10.0', $browser->getVersion() ); //Take MSIE over Trident here. -- Internet Explorer 8 on Windows 7, Internet Explorer 10 Compatibility View return true; } function testBrowserIOS() { $browser = new Browser( 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/21.0 Mobile/16B92 Safari/605.1.15' ); $this->assertEquals( Browser::BROWSER_FIREFOX, $browser->getBrowser() ); $this->assertEquals( true, $browser->isMobile() ); $this->assertEquals( '21.0', $browser->getVersion() ); return true; } function testDetectMobileBrowser() { $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)' ) ); $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' ) ); $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134' ) ); $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0' ) ); $this->assertEquals( true, Misc::detectMobileBrowser( 'Mozilla/5.0 (Linux; Android 8.0.0; SM-N9500 Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/63.0.3239.83 Mobile Safari/537.36 T7/10.13 baiduboxapp/10.13.0.11 (Baidu; P1 8.0.0)' ) ); $this->assertEquals( true, Misc::detectMobileBrowser( 'Mozilla/5.0 (Android 9; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0' ) ); $this->assertEquals( true, Misc::detectMobileBrowser( 'Mozilla/5.0 (Linux; Android 7.1.2; AFTMM Build/NS6265; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.110 Mobile Safari/537.36' ) ); $this->assertEquals( true, Misc::detectMobileBrowser( 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/21.0 Mobile/16B92 Safari/605.1.15' ) ); $this->assertEquals( true, Misc::detectMobileBrowser( 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1' ) ); return true; } function testDetectMobileBrowserPlatform() { $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)', true ) ); $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', true ) ); $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134', true ) ); $this->assertEquals( false, Misc::detectMobileBrowser( 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0', true ) ); $this->assertEquals( 'android', Misc::detectMobileBrowser( 'Mozilla/5.0 (Linux; Android 8.0.0; SM-N9500 Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/63.0.3239.83 Mobile Safari/537.36 T7/10.13 baiduboxapp/10.13.0.11 (Baidu; P1 8.0.0)', true ) ); $this->assertEquals( 'android', Misc::detectMobileBrowser( 'Mozilla/5.0 (Android 9; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0', true ) ); $this->assertEquals( 'android', Misc::detectMobileBrowser( 'Mozilla/5.0 (Linux; Android 7.1.2; AFTMM Build/NS6265; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.110 Mobile Safari/537.36', true ) ); $this->assertEquals( 'ios', Misc::detectMobileBrowser( 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/21.0 Mobile/16B92 Safari/605.1.15', true ) ); $this->assertEquals( 'ios', Misc::detectMobileBrowser( 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1', true ) ); return true; } } ?>