From 1002281dae6650684ba06d21abeba8ff8ba070d9 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 11 Jun 2014 00:54:25 +0200 Subject: handle http accept headers more gracefully --- .../lib/appframework/controller/ControllerTest.php | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/lib/appframework/controller/ControllerTest.php') 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); + } + } -- cgit v1.2.3