Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-35469 test for the new Gecko user agent handling

  • Loading branch information...
commit a4848f6ef76b6e165397e9d51faf88706a4e4dc6 1 parent ad7d20c
@skodak skodak authored
Showing with 118 additions and 2 deletions.
  1. +118 −2 lib/tests/moodlelib_test.php
View
120 lib/tests/moodlelib_test.php
@@ -49,8 +49,17 @@ class moodlelib_testcase extends advanced_testcase {
'1.5' => array('Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8) Gecko/20051107 Firefox/1.5'),
'1.5.0.1' => array('Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1'),
'2.0' => array('Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1',
- 'Ubuntu Linux AMD64' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)'),
- '3.0.6' => array('SUSE' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012700 SUSE/3.0.6-1.4 Firefox/3.0.6'),
+ 'Ubuntu Linux AMD64' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)'),
+ '3.0.6' => array('SUSE' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012700 SUSE/3.0.6-1.4 Firefox/3.0.6'),
+ '3.6' => array('Linux' => 'Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/3.6'),
+ '11.0' => array('Windows' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko Firefox/11.0'),
+ '15.0a2' => array('Windows' => 'Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0a2'),
+ '18.0' => array('Mac OS X' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:18.0) Gecko/18.0 Firefox/18.0'),
+ ),
+ 'SeaMonkey' => array(
+ '2.0' => array('Windows' => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1b3pre) Gecko/20081208 SeaMonkey/2.0'),
+ '2.1' => array('Linux' => 'Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20110609 Firefox/4.0.1 SeaMonkey/2.1'),
+ '2.3' => array('FreeBSD' => 'Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0) Gecko/20110818 Firefox/6.0 SeaMonkey/2.3'),
),
'Safari' => array(
'312' => array('Mac OS X' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312'),
@@ -248,6 +257,113 @@ function test_check_browser_version()
$this->assertTrue(check_browser_version('Firefox'));
$this->assertTrue(check_browser_version('Firefox', '1.5'));
$this->assertFalse(check_browser_version('Firefox', '3.0'));
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['1.0.6']['Windows XP'];
+ $this->assertTrue(check_browser_version('Firefox'));
+ $this->assertTrue(check_browser_version('Gecko', '1'));
+ $this->assertFalse(check_browser_version('Gecko', 20030516));
+ $this->assertFalse(check_browser_version('Gecko', 20051106));
+ $this->assertFalse(check_browser_version('Gecko', 2006010100));
+ $this->assertFalse(check_browser_version('Firefox', '1.5'));
+ $this->assertFalse(check_browser_version('Firefox', '3.0'));
+ $this->assertFalse(check_browser_version('Gecko', '2'));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['2.0']['Windows XP'];
+ $this->assertTrue(check_browser_version('Firefox'));
+ $this->assertTrue(check_browser_version('Firefox', '1.5'));
+ $this->assertTrue(check_browser_version('Gecko', '1'));
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+ $this->assertFalse(check_browser_version('Firefox', '3.0'));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['3.6']['Linux'];
+ $this->assertTrue(check_browser_version('Firefox'));
+ $this->assertTrue(check_browser_version('Firefox', '1.5'));
+ $this->assertTrue(check_browser_version('Firefox', '3.0'));
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', '3.6'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+ $this->assertFalse(check_browser_version('Firefox', '4'));
+ $this->assertFalse(check_browser_version('Firefox', '10'));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['3.6']['Linux'];
+ $this->assertTrue(check_browser_version('Firefox'));
+ $this->assertTrue(check_browser_version('Firefox', '1.5'));
+ $this->assertTrue(check_browser_version('Firefox', '3.0'));
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', '3.6'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+ $this->assertFalse(check_browser_version('Firefox', '4'));
+ $this->assertFalse(check_browser_version('Firefox', '10'));
+ $this->assertFalse(check_browser_version('Firefox', '18'));
+ $this->assertFalse(check_browser_version('Gecko', '4'));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['15.0a2']['Windows'];
+ $this->assertTrue(check_browser_version('Firefox'));
+ $this->assertTrue(check_browser_version('Firefox', '1.5'));
+ $this->assertTrue(check_browser_version('Firefox', '3.0'));
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', '3.6'));
+ $this->assertTrue(check_browser_version('Gecko', '15.0'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+ $this->assertTrue(check_browser_version('Firefox', '4'));
+ $this->assertTrue(check_browser_version('Firefox', '10'));
+ $this->assertTrue(check_browser_version('Firefox', '15'));
+ $this->assertFalse(check_browser_version('Firefox', '18'));
+ $this->assertFalse(check_browser_version('Gecko', '18'));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['18.0']['Mac OS X'];
+ $this->assertTrue(check_browser_version('Firefox'));
+ $this->assertTrue(check_browser_version('Firefox', '1.5'));
+ $this->assertTrue(check_browser_version('Firefox', '3.0'));
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', '3.6'));
+ $this->assertTrue(check_browser_version('Gecko', '15.0'));
+ $this->assertTrue(check_browser_version('Gecko', '18.0'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+ $this->assertTrue(check_browser_version('Firefox', '4'));
+ $this->assertTrue(check_browser_version('Firefox', '10'));
+ $this->assertTrue(check_browser_version('Firefox', '15'));
+ $this->assertTrue(check_browser_version('Firefox', '18'));
+ $this->assertFalse(check_browser_version('Firefox', '19'));
+ $this->assertFalse(check_browser_version('Gecko', '19'));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['SeaMonkey']['2.0']['Windows'];
+
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+ $this->assertFalse(check_browser_version('Gecko', '3.6'));
+ $this->assertFalse(check_browser_version('Gecko', '4.0'));
+ $this->assertFalse(check_browser_version('Firefox'));
+
+ $_SERVER['HTTP_USER_AGENT'] = $this->user_agents['SeaMonkey']['2.1']['Linux'];
+ $this->assertTrue(check_browser_version('Gecko', '2'));
+ $this->assertTrue(check_browser_version('Gecko', '3.6'));
+ $this->assertTrue(check_browser_version('Gecko', '4.0'));
+ $this->assertTrue(check_browser_version('Gecko', 20030516));
+ $this->assertTrue(check_browser_version('Gecko', 20051106));
+ $this->assertTrue(check_browser_version('Gecko', 2006010100));
+ $this->assertTrue(check_browser_version('Firefox'));
+ $this->assertTrue(check_browser_version('Firefox', 4.0));
+ $this->assertFalse(check_browser_version('Firefox', 5));
+ $this->assertFalse(check_browser_version('Gecko', '18.0'));
+
}
function test_get_browser_version_classes() {
Please sign in to comment.
Something went wrong with that request. Please try again.