diff --git a/appinfo/routes.php b/appinfo/routes.php index 51df82a45..f93510885 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -73,7 +73,7 @@ 'verb' => 'OPTIONS', 'requirements' => [ 'path' => '.+', - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], @@ -83,7 +83,7 @@ 'url' => '/api/{apiVersion}/forms', 'verb' => 'GET', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -91,7 +91,7 @@ 'url' => '/api/{apiVersion}/form', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -99,7 +99,7 @@ 'url' => '/api/{apiVersion}/form/{id}', 'verb' => 'GET', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -107,7 +107,7 @@ 'url' => '/api/{apiVersion}/form/clone/{id}', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], // TODO: Remove POST in next API release @@ -116,7 +116,7 @@ 'url' => '/api/{apiVersion}/form/update', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -124,7 +124,7 @@ 'url' => '/api/{apiVersion}/form/update', 'verb' => 'PATCH', 'requirements' => [ - 'apiVersion' => 'v2.2' + 'apiVersion' => 'v2\.[2-3]' ] ], [ @@ -132,7 +132,7 @@ 'url' => '/api/{apiVersion}/form/transfer', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2.2' + 'apiVersion' => 'v2\.[2-3]' ] ], [ @@ -140,7 +140,7 @@ 'url' => '/api/{apiVersion}/form/{id}', 'verb' => 'DELETE', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -148,7 +148,7 @@ 'url' => '/api/{apiVersion}/partial_form/{hash}', 'verb' => 'GET', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -156,7 +156,7 @@ 'url' => '/api/{apiVersion}/shared_forms', 'verb' => 'GET', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], @@ -166,7 +166,7 @@ 'url' => '/api/{apiVersion}/question', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], // TODO: Remove POST in next API release @@ -175,7 +175,7 @@ 'url' => '/api/{apiVersion}/question/update', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -183,7 +183,7 @@ 'url' => '/api/{apiVersion}/question/update', 'verb' => 'PATCH', 'requirements' => [ - 'apiVersion' => 'v2.2' + 'apiVersion' => 'v2\.[2-3]' ] ], // TODO: Remove POST in next API release @@ -192,7 +192,7 @@ 'url' => '/api/{apiVersion}/question/reorder', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -200,7 +200,7 @@ 'url' => '/api/{apiVersion}/question/reorder', 'verb' => 'PUT', 'requirements' => [ - 'apiVersion' => 'v2.2' + 'apiVersion' => 'v2\.[2-3]' ] ], [ @@ -208,15 +208,15 @@ 'url' => '/api/{apiVersion}/question/{id}', 'verb' => 'DELETE', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ - 'name' => 'api#duplicateQuestion', + 'name' => 'api#cloneQuestion', 'url' => '/api/{apiVersion}/question/clone/{id}', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2.1' + 'apiVersion' => 'v2.3' ] ], @@ -226,7 +226,7 @@ 'url' => '/api/{apiVersion}/option', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], // TODO: Remove POST in next API release @@ -235,7 +235,7 @@ 'url' => '/api/{apiVersion}/option/update', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -243,7 +243,7 @@ 'url' => '/api/{apiVersion}/option/update', 'verb' => 'PATCH', 'requirements' => [ - 'apiVersion' => 'v2.2' + 'apiVersion' => 'v2\.[2-3]' ] ], [ @@ -251,7 +251,7 @@ 'url' => '/api/{apiVersion}/option/{id}', 'verb' => 'DELETE', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], @@ -261,7 +261,7 @@ 'url' => '/api/{apiVersion}/share', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -269,7 +269,7 @@ 'url' => '/api/{apiVersion}/share/{id}', 'verb' => 'DELETE', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], // TODO: Remove POST in next API release @@ -286,7 +286,7 @@ 'url' => '/api/{apiVersion}/share/update', 'verb' => 'PATCH', 'requirements' => [ - 'apiVersion' => 'v2.2' + 'apiVersion' => 'v2\.[2-3]' ] ], @@ -296,7 +296,7 @@ 'url' => '/api/{apiVersion}/submissions/{hash}', 'verb' => 'GET', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -304,7 +304,7 @@ 'url' => '/api/{apiVersion}/submissions/export/{hash}', 'verb' => 'GET', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -312,7 +312,7 @@ 'url' => '/api/{apiVersion}/submissions/export', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -320,7 +320,7 @@ 'url' => '/api/{apiVersion}/submissions/{formId}', 'verb' => 'DELETE', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -328,7 +328,7 @@ 'url' => '/api/{apiVersion}/submission/insert', 'verb' => 'POST', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], [ @@ -336,7 +336,7 @@ 'url' => '/api/{apiVersion}/submission/{id}', 'verb' => 'DELETE', 'requirements' => [ - 'apiVersion' => 'v2(\.[1-2])?' + 'apiVersion' => 'v2(\.[1-3])?' ] ], ] diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 252481f28..373f0af3d 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -717,14 +717,14 @@ public function deleteQuestion(int $id): DataResponse { * @CORS * @NoAdminRequired * - * Duplicate a question + * Clone a question * * @param int $id the question id * @return DataResponse * @throws OCSBadRequestException|OCSForbiddenException */ - public function duplicateQuestion(int $id): DataResponse { - $this->logger->debug('Question to be duplicated: {id}', [ + public function cloneQuestion(int $id): DataResponse { + $this->logger->debug('Question to be cloned: {id}', [ 'id' => $id ]); diff --git a/tests/Integration/Api/ApiV2Test.php b/tests/Integration/Api/ApiV2Test.php index f14fb97b3..1fdcb6341 100644 --- a/tests/Integration/Api/ApiV2Test.php +++ b/tests/Integration/Api/ApiV2Test.php @@ -930,23 +930,23 @@ public function testDeleteQuestion(array $fullFormExpected) { $this->testGetFullForm($fullFormExpected); } - public function dataDuplicateQuestion() { + public function dataCloneQuestion() { $fullFormExpected = $this->dataGetFullForm()['getFullForm']['expected']; array_splice($fullFormExpected['questions'][1]['options'], 0, 1); return [ - 'duplicateQuestion' => [ + 'clonedQuestion' => [ 'fullFormExpected' => $fullFormExpected ] ]; } /** - * @dataProvider dataDuplicateQuestion + * @dataProvider dataCloneQuestion * @param array $fullFormExpected */ - public function testDuplicateQuestion(array $fullFormExpected) { - $resp = $this->http->request('POST', "api/v2/question/{$this->testForms[0]['questions'][0]['id']}"); + public function testCloneQuestion(array $fullFormExpected) { + $resp = $this->http->request('POST', 'api/v2.3/question/' . $this->testForms[0]['questions'][0]['id']); $data = $this->OcsResponse2Data($resp); $this->assertEquals(200, $resp->getStatusCode());