summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-12-12 11:32:56 +0100
committerVincent Petry <pvince81@owncloud.com>2013-12-19 18:40:22 +0100
commit09bd5bd517fee80e8b44b7645b51a8ba482a4d7c (patch)
treef61ac99c6d759701a723b1fee9ea09d90941b492 /tests
parent82bf1f9c8ccbfed39790d22b2fbea2c5286122dc (diff)
downloadnextcloud-server-09bd5bd517fee80e8b44b7645b51a8ba482a4d7c.tar.gz
nextcloud-server-09bd5bd517fee80e8b44b7645b51a8ba482a4d7c.zip
Added isUserAgent() method to request
- added isUserAgent() method to OC_Request which makes it possible to test it - OC_Response::setContentDisposition now uses OC_Request::isUserAgent()
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/request.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/lib/request.php b/tests/lib/request.php
index 090cebc9231..c6401a57144 100644
--- a/tests/lib/request.php
+++ b/tests/lib/request.php
@@ -70,4 +70,54 @@ class Test_Request extends PHPUnit_Framework_TestCase {
array('/oc/core1', '/oc/core/index.php'),
);
}
+
+ /**
+ * @dataProvider userAgentProvider
+ */
+ public function testUserAgent($testAgent, $userAgent, $matches) {
+ $_SERVER['HTTP_USER_AGENT'] = $testAgent;
+ $this->assertEquals($matches, OC_Request::isUserAgent($userAgent));
+ }
+
+ function userAgentProvider() {
+ return array(
+ array(
+ 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
+ OC_Request::USER_AGENT_IE,
+ true
+ ),
+ array(
+ 'Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0',
+ OC_Request::USER_AGENT_IE,
+ false
+ ),
+ array(
+ 'Mozilla/5.0 (Linux; Android 4.4; Nexus 4 Build/KRT16S) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36',
+ OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME,
+ true
+ ),
+ array(
+ 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
+ OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME,
+ false
+ ),
+ // test two values
+ array(
+ 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
+ array(
+ OC_Request::USER_AGENT_IE,
+ OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME,
+ ),
+ true
+ ),
+ array(
+ 'Mozilla/5.0 (Linux; Android 4.4; Nexus 4 Build/KRT16S) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36',
+ array(
+ OC_Request::USER_AGENT_IE,
+ OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME,
+ ),
+ true
+ ),
+ );
+ }
}