aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-06-12 13:28:03 +0200
committerVincent Petry <pvince81@owncloud.com>2014-06-12 13:28:03 +0200
commit3e1576011fbfa4a6e1e8020142cbad4ff38f9115 (patch)
tree38f7c73a701b9957de66fdf5658e13bb635ff0e4 /tests
parent5def2a72dddb92bb2289839054ae39c1850c891d (diff)
parent93169eca1e754bf9a91599f7a7a84e461cfd974f (diff)
downloadnextcloud-server-3e1576011fbfa4a6e1e8020142cbad4ff38f9115.tar.gz
nextcloud-server-3e1576011fbfa4a6e1e8020142cbad4ff38f9115.zip
Merge pull request #8980 from owncloud/better-accept-header
handle http accept headers more gracefully
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/appframework/controller/ControllerTest.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lib/appframework/controller/ControllerTest.php b/tests/lib/appframework/controller/ControllerTest.php
index 65144e78f53..e97ec548939 100644
--- a/tests/lib/appframework/controller/ControllerTest.php
+++ b/tests/lib/appframework/controller/ControllerTest.php
@@ -30,6 +30,14 @@ use OCP\AppFramework\Http\JSONResponse;
class ChildController extends Controller {
+
+ public function __construct($appName, $request) {
+ parent::__construct($appName, $request);
+ $this->registerResponder('tom', function ($respone) {
+ return 'hi';
+ });
+ }
+
public function custom($in) {
$this->registerResponder('json', function ($response) {
return new JSONResponse(array(strlen($response)));
@@ -161,5 +169,29 @@ class ControllerTest extends \PHPUnit_Framework_TestCase {
}
+ public function testDefaultResponderToJSON() {
+ $responder = $this->controller->getResponderByHTTPHeader('*/*');
+
+ $this->assertEquals('json', $responder);
+ }
+
+
+ public function testResponderAcceptHeaderParsed() {
+ $responder = $this->controller->getResponderByHTTPHeader(
+ '*/*, application/tom, application/json'
+ );
+
+ $this->assertEquals('tom', $responder);
+ }
+
+
+ public function testResponderAcceptHeaderParsedUpperCase() {
+ $responder = $this->controller->getResponderByHTTPHeader(
+ '*/*, apPlication/ToM, application/json'
+ );
+
+ $this->assertEquals('tom', $responder);
+ }
+
}