summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-07-27 15:28:35 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-07-27 15:28:35 +0200
commit8bdd0adceecfa7382140022819546acae61ed0a5 (patch)
treeff968085de18a5b43a493c656720314e68657b8c /tests
parent10726dd00df37be77c3088302e16e64b09a6d25f (diff)
downloadnextcloud-server-8bdd0adceecfa7382140022819546acae61ed0a5.tar.gz
nextcloud-server-8bdd0adceecfa7382140022819546acae61ed0a5.zip
Support subdir in the OCS v2 endpoint
We should check against the ending substring since people could run their nextcloud in a subfolder. * Added test
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
index 5eff056eebc..7d8cadc677f 100644
--- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
@@ -139,4 +139,34 @@ class OCSMiddlewareTest extends \Test\TestCase {
}
}
+ /**
+ * @dataProvider dataAfterException
+ *
+ * @param Controller $controller
+ * @param \Exception $exception
+ * @param bool $forward
+ * @param string $message
+ * @param int $code
+ */
+ public function testAfterExceptionOCSv2SubFolder($controller, $exception, $forward, $message = '', $code = 0) {
+ $this->request
+ ->method('getScriptName')
+ ->willReturn('/mysubfolder/ocs/v2.php');
+ $OCSMiddleware = new OCSMiddleware($this->request);
+
+ try {
+ $result = $OCSMiddleware->afterException($controller, 'method', $exception);
+ $this->assertFalse($forward);
+
+ $this->assertInstanceOf('OCP\AppFramework\Http\OCSResponse', $result);
+
+ $this->assertSame($message, $this->invokePrivate($result, 'message'));
+ $this->assertSame($code, $this->invokePrivate($result, 'statuscode'));
+ $this->assertSame($code, $result->getStatus());
+ } catch (\Exception $e) {
+ $this->assertTrue($forward);
+ $this->assertEquals($exception, $e);
+ }
+ }
+
}