-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
181 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details | ||
|
||
language: php | ||
php: | ||
- 5.3 | ||
language: php | ||
|
||
env: | ||
- DB=MYSQL CORE_RELEASE=3.0 | ||
- DB=PGSQL CORE_RELEASE=3.0 | ||
sudo: false | ||
|
||
matrix: | ||
include: | ||
- php: 5.3 | ||
env: DB=MYSQL CORE_RELEASE=3.0 | ||
- php: 5.4 | ||
env: DB=PGSQL CORE_RELEASE=3.0 | ||
- php: 5.5 | ||
env: DB=SQLITE CORE_RELEASE=3.0 | ||
- php: 5.6 | ||
env: DB=MYSQL CORE_RELEASE=3.0 | ||
|
||
before_script: | ||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support | ||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/cms | ||
- cd ~/builds/ss | ||
|
||
script: | ||
- phpunit mobile/tests/ | ||
script: | ||
- vendor/bin/phpunit mobile/tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
class MobileBrowserDetectorTest extends SapphireTest { | ||
|
||
public function testIsTablet() { | ||
$this->assertTrue(MobileBrowserDetector::is_tablet( | ||
'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13', | ||
'XOOM tablet, contains "android" but not "mobile"' | ||
)); | ||
$this->assertFalse(MobileBrowserDetector::is_tablet( | ||
'Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1', | ||
'Nexus One, contains "mobile" and "android"' | ||
)); | ||
// This is where this approach falls down ... can't detect MS Surface usage. | ||
// See http://www.brettjankord.com/2013/01/10/active-development-on-categorizr-has-come-to-an-end/ | ||
$this->assertFalse(MobileBrowserDetector::is_tablet( | ||
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)' | ||
)); | ||
} | ||
|
||
public function testTabletIsMobile() { | ||
$tabletUa = 'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13'; | ||
$mobileUa = 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; | ||
$desktopUa = 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))'; | ||
|
||
$orig = MobileBrowserDetector::$tablet_is_mobile; | ||
|
||
MobileBrowserDetector::$tablet_is_mobile = true; | ||
$this->assertTrue(MobileBrowserDetector::is_mobile($tabletUa)); | ||
$this->assertTrue(MobileBrowserDetector::is_mobile($mobileUa)); | ||
$this->assertFalse(MobileBrowserDetector::is_mobile($desktopUa)); | ||
|
||
MobileBrowserDetector::$tablet_is_mobile = false; | ||
$this->assertFalse(MobileBrowserDetector::is_mobile($tabletUa)); | ||
$this->assertTrue(MobileBrowserDetector::is_mobile($mobileUa)); | ||
$this->assertFalse(MobileBrowserDetector::is_mobile($desktopUa)); | ||
|
||
MobileBrowserDetector::$tablet_is_mobile = null; | ||
// Technically this is a bug, but its the standard module check | ||
$this->assertFalse(MobileBrowserDetector::is_mobile($tabletUa)); | ||
$this->assertTrue(MobileBrowserDetector::is_mobile($mobileUa)); | ||
$this->assertFalse(MobileBrowserDetector::is_mobile($desktopUa)); | ||
|
||
MobileBrowserDetector::$tablet_is_mobile = $orig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.