diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-01 15:04:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 15:04:09 +0200 |
commit | 7ffed2deae32fb106d245442cb94104242946da1 (patch) | |
tree | e045aa9276bb18b14eea6792621dca6ecd8e3ec4 /tests | |
parent | 59d240c3aaaaa351ecc04c79b7ad6abc8f67363d (diff) | |
parent | 21a87d3c2eeaad6034df505f173c75a0ab804225 (diff) | |
download | nextcloud-server-7ffed2deae32fb106d245442cb94104242946da1.tar.gz nextcloud-server-7ffed2deae32fb106d245442cb94104242946da1.zip |
Merge pull request #1221 from nextcloud/proper_204_304_response
No body or content-length for 204 and 304 responses
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AppFramework/AppTest.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php index 92ebd1f81e7..93b8768e674 100644 --- a/tests/lib/AppFramework/AppTest.php +++ b/tests/lib/AppFramework/AppTest.php @@ -25,6 +25,7 @@ namespace Test\AppFramework; use OC\AppFramework\App; +use OCP\AppFramework\Http; use OCP\AppFramework\Http\Response; @@ -134,7 +135,7 @@ class AppTest extends \Test\TestCase { public function testOutputIsPrinted(){ - $return = [null, [], [], $this->output, new Response()]; + $return = [Http::STATUS_OK, [], [], $this->output, new Response()]; $this->dispatcher->expects($this->once()) ->method('dispatch') ->with($this->equalTo($this->controller), @@ -146,6 +147,32 @@ class AppTest extends \Test\TestCase { App::main($this->controllerName, $this->controllerMethod, $this->container, []); } + public function dataNoOutput() { + return [ + [Http::STATUS_NO_CONTENT], + [Http::STATUS_NOT_MODIFIED], + ]; + } + + /** + * @dataProvider dataNoOutput + * @param int $statusCode + */ + public function testNoOutput($statusCode) { + $return = [$statusCode, [], [], $this->output, new Response()]; + $this->dispatcher->expects($this->once()) + ->method('dispatch') + ->with($this->equalTo($this->controller), + $this->equalTo($this->controllerMethod)) + ->will($this->returnValue($return)); + $this->io->expects($this->once()) + ->method('setHeader') + ->with($this->equalTo($statusCode)); + $this->io->expects($this->never()) + ->method('setOutput'); + App::main($this->controllerName, $this->controllerMethod, $this->container, []); + } + public function testCallbackIsCalled(){ $mock = $this->getMockBuilder('OCP\AppFramework\Http\ICallbackResponse') |