summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-08-09 10:03:16 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-10 12:40:26 +0200
commit1f370c97ed482a2217b49c949e93436d07f83157 (patch)
tree2db9c7e0c30bbd9fc5a02e00f58d04cd1d645520 /tests
parentcdb574ca264759b5571284621fc4970af895767d (diff)
downloadnextcloud-server-1f370c97ed482a2217b49c949e93436d07f83157.tar.gz
nextcloud-server-1f370c97ed482a2217b49c949e93436d07f83157.zip
OCSController requires DataResponse
The OCS Controller requires a DataResponse object to be returned. This means that all error handling will have to be done via exceptions thrown and handling in the middleware.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/Controller/OCSControllerTest.php57
1 files changed, 5 insertions, 52 deletions
diff --git a/tests/lib/AppFramework/Controller/OCSControllerTest.php b/tests/lib/AppFramework/Controller/OCSControllerTest.php
index 7dcbd189cd5..9c9214181a4 100644
--- a/tests/lib/AppFramework/Controller/OCSControllerTest.php
+++ b/tests/lib/AppFramework/Controller/OCSControllerTest.php
@@ -75,8 +75,8 @@ class OCSControllerTest extends \Test\TestCase {
$expected = "<?xml version=\"1.0\"?>\n" .
"<ocs>\n" .
" <meta>\n" .
- " <status>failure</status>\n" .
- " <statuscode>400</statuscode>\n" .
+ " <status>ok</status>\n" .
+ " <statuscode>100</statuscode>\n" .
" <message>OK</message>\n" .
" <totalitems></totalitems>\n" .
" <itemsperpage></itemsperpage>\n" .
@@ -86,54 +86,12 @@ class OCSControllerTest extends \Test\TestCase {
" </data>\n" .
"</ocs>\n";
- $params = [
- 'data' => [
- 'test' => 'hi'
- ],
- 'statuscode' => 400
- ];
+ $params = new DataResponse(['test' => 'hi']);
$out = $controller->buildResponse($params, 'xml')->render();
$this->assertEquals($expected, $out);
}
-
- public function testXMLDataResponse() {
- $controller = new ChildOCSController('app', new Request(
- [],
- $this->getMockBuilder('\OCP\Security\ISecureRandom')
- ->disableOriginalConstructor()
- ->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
- ->disableOriginalConstructor()
- ->getMock()
- ));
- $expected = "<?xml version=\"1.0\"?>\n" .
- "<ocs>\n" .
- " <meta>\n" .
- " <status>failure</status>\n" .
- " <statuscode>400</statuscode>\n" .
- " <message>OK</message>\n" .
- " <totalitems></totalitems>\n" .
- " <itemsperpage></itemsperpage>\n" .
- " </meta>\n" .
- " <data>\n" .
- " <test>hi</test>\n" .
- " </data>\n" .
- "</ocs>\n";
-
- $params = new DataResponse([
- 'data' => [
- 'test' => 'hi'
- ],
- 'statuscode' => 400
- ]);
-
- $out = $controller->buildResponse($params, 'xml')->render();
- $this->assertEquals($expected, $out);
- }
-
-
public function testJSON() {
$controller = new ChildOCSController('app', new Request(
[],
@@ -144,14 +102,9 @@ class OCSControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock()
));
- $expected = '{"ocs":{"meta":{"status":"failure","statuscode":400,"message":"OK",' .
+ $expected = '{"ocs":{"meta":{"status":"ok","statuscode":100,"message":"OK",' .
'"totalitems":"","itemsperpage":""},"data":{"test":"hi"}}}';
- $params = [
- 'data' => [
- 'test' => 'hi'
- ],
- 'statuscode' => 400
- ];
+ $params = new DataResponse(['test' => 'hi']);
$out = $controller->buildResponse($params, 'json')->render();
$this->assertEquals($expected, $out);