summaryrefslogtreecommitdiff
path: root/tests/Framework/Browser.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-01-30 09:12:57 +0100
committerThomas Bruederli <thomas@roundcube.net>2014-01-30 09:12:57 +0100
commit8c893b79d230cc844226bdf3b1de95cd5a99ecb2 (patch)
treef8e6e1df519c9b85bd16bdc31f1ae6a3b16ce6e7 /tests/Framework/Browser.php
parent1978ae97a5e0feb8d205c5fcbaa2cc16ce3ffc28 (diff)
Branching off for release 1.0
Diffstat (limited to 'tests/Framework/Browser.php')
-rw-r--r--tests/Framework/Browser.php234
1 files changed, 0 insertions, 234 deletions
diff --git a/tests/Framework/Browser.php b/tests/Framework/Browser.php
deleted file mode 100644
index a042572a8..000000000
--- a/tests/Framework/Browser.php
+++ /dev/null
@@ -1,234 +0,0 @@
-<?php
-
-/**
- * Test class to test rcube_browser class
- *
- * @package Tests
- */
-class Framework_Browser extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Class constructor
- */
- function test_class()
- {
- $object = new rcube_browser();
-
- $this->assertInstanceOf('rcube_browser', $object, "Class constructor");
- }
-
- /**
- * @dataProvider browsers
- */
- function test_browser($useragent, $opera, $chrome, $ie, $ns, $safari, $mz)
- {
-
- $object = $this->getBrowser($useragent);
-
- $this->assertEquals($opera, $object->opera, 'Check for Opera failed');
- $this->assertEquals($chrome, $object->chrome, 'Check for Chrome failed');
- $this->assertEquals($ie, $object->ie, 'Check for IE failed');
- $this->assertEquals($ns, $object->ns, 'Check for NS failed');
- $this->assertEquals($safari, $object->safari, 'Check for Safari failed');
- $this->assertEquals($mz, $object->mz, 'Check for MZ failed');
- }
-
- /**
- * @dataProvider os
- */
- function test_os($useragent, $windows, $linux, $unix, $mac)
- {
- $object = $this->getBrowser($useragent);
-
- $this->assertEquals($windows, $object->win, 'Check Result of Windows');
- $this->assertEquals($linux, $object->linux, 'Check Result of Linux');
- $this->assertEquals($mac, $object->mac, 'Check Result of Mac');
- $this->assertEquals($unix, $object->unix, 'Check Result of Unix');
-
- }
-
- /**
- * @dataProvider versions
- */
- function test_version($useragent, $version)
- {
- $object = $this->getBrowser($useragent);
- $this->assertEquals($version, $object->ver);
- }
-
- /**
- * @dataProvider dom
- */
- function test_dom($useragent, $dom)
- {
- $object = $this->getBrowser($useragent);
- $this->assertEquals($dom, $object->dom);
-
- }
-
- /**
- * @dataProvider pngalpha
- */
- function test_pngalpha($useragent, $pngalpha)
- {
- $object = $this->getBrowser($useragent);
- $this->assertEquals($pngalpha, $object->pngalpha);
- }
-
- /**
- * @dataProvider imgdata
- */
- function test_imgdata($useragent, $imgdata)
- {
- $object = $this->getBrowser($useragent);
- $this->assertEquals($imgdata, $object->imgdata);
- }
-
- function versions()
- {
- return $this->extractDataSet(array('version'));
- }
-
- function pngalpha()
- {
- return $this->extractDataSet(array('canPNGALPHA'));
- }
-
- function imgdata()
- {
- return $this->extractDataSet(array('canIMGDATA'));
- }
-
- private function extractDataSet($keys)
- {
- $keys = array_merge(array('useragent'), $keys);
-
- $browser = $this->useragents();
-
- $extracted = array();
-
- foreach ($browser as $label => $data) {
- foreach($keys as $key) {
- $extracted[$data['useragent']][] = $data[$key];
- }
-
- }
-
- return $extracted;
- }
-
- function lang()
- {
- return $this->extractDataSet(array('lang'));
- }
-
- function dom()
- {
- return $this->extractDataSet(array('hasDOM'));
- }
-
- function browsers()
- {
- return $this->extractDataSet(array('isOpera','isChrome','isIE','isNS','isSafari','isMZ'));
- }
-
- function useragents()
- {
- return array(
- 'WIN: Mozilla Firefox ' => array(
- 'useragent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1',
- 'version' => '1.8', //Version
- 'isWin' => true, //isWindows
- 'isLinux' => false,
- 'isMac' => false, //isMac
- 'isUnix' => false, //isUnix
- 'isOpera' => false, //isOpera
- 'isChrome' => false, //isChrome
- 'isIE' => false, //isIE
- 'isNS' => false, //isNS
- 'isSafari' => false, //isSafari
- 'isMZ' => true, //isMZ
- 'lang' => 'en-US', //lang
- 'hasDOM' => true, //hasDOM
- 'canPNGALPHA' => true, //canPNGALPHA
- 'canIMGDATA' => true, //canIMGDATA
- ),
- 'LINUX: Bon Echo ' => array(
- 'useragent' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20070222 BonEcho/2.0.0.1',
- 'version' => '1.8', //Version
- 'isWin' => false, //isWindows
- 'isLinux' => true,
- 'isMac' => false, //isMac
- 'isUnix' => false, //isUnix
- 'isOpera' => false, //isOpera
- 'isChrome' => false, //isChrome
- 'isIE' => false, //isIE
- 'isNS' => false, //isNS
- 'isSafari' => false, //isSafari
- 'isMZ' => true, //isMZ
- 'lang' => 'en-US', //lang
- 'hasDOM' => true, //hasDOM
- 'canPNGALPHA' => true, //canPNGALPHA
- 'canIMGDATA' => true, //canIMGDATA
- ),
-
- 'Chrome Mac' => array(
- 'useragent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.461.0 Safari/534.3',
- 'version' => '6', //Version
- 'isWin' => false, //isWindows
- 'isLinux' => false,
- 'isMac' => true, //isMac
- 'isUnix' => false, //isUnix
- 'isOpera' => false, //isOpera
- 'isChrome' => true, //isChrome
- 'isIE' => false, //isIE
- 'isNS' => false, //isNS
- 'isSafari' => false, //isSafari
- 'isMZ' => false, //isMZ
- 'lang' => 'en-US', //lang
- 'hasDOM' => false, //hasDOM
- 'canPNGALPHA' => false, //canPNGALPHA
- 'canIMGDATA' => true, //canIMGDATA
- ),
-
- 'IE 11' => array(
- 'useragent' => 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko',
- 'version' => '11.0', //Version
- 'isWin' => true, //isWindows
- 'isLinux' => false,
- 'isMac' => false, //isMac
- 'isUnix' => false, //isUnix
- 'isOpera' => false, //isOpera
- 'isChrome' => false, //isChrome
- 'isIE' => true, //isIE
- 'isNS' => false, //isNS
- 'isSafari' => false, //isSafari
- 'isMZ' => false, //isMZ
- 'lang' => '', //lang
- 'hasDOM' => true, //hasDOM
- 'canPNGALPHA' => true, //canPNGALPHA
- 'canIMGDATA' => false, //canIMGDATA
- ),
- );
- }
-
- function os()
- {
- return $this->extractDataSet(array('isWin','isLinux','isUnix','isMac'));
- }
-
- /**
- * @param string $useragent
- * @return rcube_browser
- */
- private function getBrowser($useragent)
- {
- /** @var $object rcube_browser */
- $_SERVER['HTTP_USER_AGENT'] = $useragent;
-
- $object = new rcube_browser();
-
- return $object;
- }
-}