@@ -89,6 +89,9 @@ public function dataAfterException() {
8989 * @param int $code
9090 */
9191 public function testAfterException ($ controller , $ exception , $ forward , $ message = '' , $ code = 0 ) {
92+ $ this ->request
93+ ->method ('getScriptName ' )
94+ ->willReturn ('/mysubfolder/ocs/v1.php ' );
9295 $ OCSMiddleware = new OCSMiddleware ($ this ->request );
9396
9497 try {
@@ -105,4 +108,34 @@ public function testAfterException($controller, $exception, $forward, $message =
105108 }
106109 }
107110
111+ /**
112+ * @dataProvider dataAfterException
113+ *
114+ * @param Controller $controller
115+ * @param \Exception $exception
116+ * @param bool $forward
117+ * @param string $message
118+ * @param int $code
119+ */
120+ public function testAfterExceptionOCSv2SubFolder ($ controller , $ exception , $ forward , $ message = '' , $ code = 0 ) {
121+ $ this ->request
122+ ->method ('getScriptName ' )
123+ ->willReturn ('/mysubfolder/ocs/v2.php ' );
124+ $ OCSMiddleware = new OCSMiddleware ($ this ->request );
125+
126+ try {
127+ $ result = $ OCSMiddleware ->afterException ($ controller , 'method ' , $ exception );
128+ $ this ->assertFalse ($ forward );
129+
130+ $ this ->assertInstanceOf ('OCP\AppFramework\Http\OCSResponse ' , $ result );
131+
132+ $ this ->assertSame ($ message , $ this ->invokePrivate ($ result , 'message ' ));
133+ $ this ->assertSame ($ code , $ this ->invokePrivate ($ result , 'statuscode ' ));
134+ $ this ->assertSame ($ code , $ result ->getStatus ());
135+ } catch (\Exception $ e ) {
136+ $ this ->assertTrue ($ forward );
137+ $ this ->assertEquals ($ exception , $ e );
138+ }
139+ }
140+
108141}
0 commit comments