diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-06-11 00:54:25 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-06-11 00:54:25 +0200 |
commit | 1002281dae6650684ba06d21abeba8ff8ba070d9 (patch) | |
tree | a817c33678ccf52526c15e0027f16836a293b968 /tests | |
parent | 077a542d59ea5c992ebb1b3ac0e6117f6289582c (diff) | |
download | nextcloud-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.php | 23 |
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); + } + } |