diff options
Diffstat (limited to 'tests/lib/appframework/controller/ControllerTest.php')
-rw-r--r-- | tests/lib/appframework/controller/ControllerTest.php | 32 |
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); + } + } |