summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-06-11 00:54:25 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-06-11 00:54:25 +0200
commit1002281dae6650684ba06d21abeba8ff8ba070d9 (patch)
treea817c33678ccf52526c15e0027f16836a293b968 /tests
parent077a542d59ea5c992ebb1b3ac0e6117f6289582c (diff)
downloadnextcloud-server-1002281dae6650684ba06d21abeba8ff8ba070d9.tar.gz
nextcloud-server-1002281dae6650684ba06d21abeba8ff8ba070d9.zip
handle http accept headers more gracefully
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/appframework/controller/ControllerTest.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/lib/appframework/controller/ControllerTest.php b/tests/lib/appframework/controller/ControllerTest.php
index 65144e78f53..1a09925ef69 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,20 @@ 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);
+ }
+
}