From 2a38ba10f7debca739179b6b036420a1b2542835 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 16 May 2024 19:05:14 +0200 Subject: [PATCH] fix: Fix Psalm, OpenAPI and unit tests Signed-off-by: Joas Schilling --- lib/Controller/CallController.php | 2 +- openapi-full.json | 20 +++++++++++++++----- openapi.json | 20 +++++++++++++++----- src/types/openapi/openapi-full.ts | 4 +++- src/types/openapi/openapi.ts | 4 +++- tests/php/Service/ParticipantServiceTest.php | 6 +++++- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index 805bd047f47..6e5021bb21a 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -162,7 +162,7 @@ public function joinCall(?int $flags = null, ?int $forcePermissions = null, bool * Ring an attendee * * @param int $attendeeId ID of the attendee to ring - * @return DataResponse, array{}> + * @return DataResponse, array{}>|DataResponse * * 200: Attendee rang successfully * 400: Ringing attendee is not possible diff --git a/openapi-full.json b/openapi-full.json index 8aec51d898f..f1a25c4f448 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -4045,8 +4045,8 @@ } } }, - "400": { - "description": "Ringing attendee is not possible", + "404": { + "description": "Attendee could not be found", "content": { "application/json": { "schema": { @@ -4073,8 +4073,8 @@ } } }, - "404": { - "description": "Attendee could not be found", + "400": { + "description": "Ringing attendee is not possible", "content": { "application/json": { "schema": { @@ -4093,7 +4093,17 @@ "meta": { "$ref": "#/components/schemas/OCSMeta" }, - "data": {} + "data": { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string" + } + } + } } } } diff --git a/openapi.json b/openapi.json index a0d74b9d13c..61cf9f21f50 100644 --- a/openapi.json +++ b/openapi.json @@ -3932,8 +3932,8 @@ } } }, - "400": { - "description": "Ringing attendee is not possible", + "404": { + "description": "Attendee could not be found", "content": { "application/json": { "schema": { @@ -3960,8 +3960,8 @@ } } }, - "404": { - "description": "Attendee could not be found", + "400": { + "description": "Ringing attendee is not possible", "content": { "application/json": { "schema": { @@ -3980,7 +3980,17 @@ "meta": { "$ref": "#/components/schemas/OCSMeta" }, - "data": {} + "data": { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string" + } + } + } } } } diff --git a/src/types/openapi/openapi-full.ts b/src/types/openapi/openapi-full.ts index 66bd34df612..ddf13c64a98 100644 --- a/src/types/openapi/openapi-full.ts +++ b/src/types/openapi/openapi-full.ts @@ -1796,7 +1796,9 @@ export type operations = { "application/json": { ocs: { meta: components["schemas"]["OCSMeta"]; - data: unknown; + data: { + error: string; + }; }; }; }; diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index 86e715f60d2..8370ecec756 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -1619,7 +1619,9 @@ export type operations = { "application/json": { ocs: { meta: components["schemas"]["OCSMeta"]; - data: unknown; + data: { + error: string; + }; }; }; }; diff --git a/tests/php/Service/ParticipantServiceTest.php b/tests/php/Service/ParticipantServiceTest.php index ca75f26b7b5..9a68aae11f1 100644 --- a/tests/php/Service/ParticipantServiceTest.php +++ b/tests/php/Service/ParticipantServiceTest.php @@ -29,6 +29,7 @@ use OCP\IGroupManager; use OCP\IUserManager; use OCP\Security\ISecureRandom; +use OCP\UserStatus\IManager; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -50,6 +51,7 @@ class ParticipantServiceTest extends TestCase { protected BackendNotifier&MockObject $federationBackendNotifier; protected ITimeFactory&MockObject $time; protected ICacheFactory&MockObject $cacheFactory; + protected IManager&MockObject $userStatusManager; private ?ParticipantService $service = null; @@ -70,6 +72,7 @@ public function setUp(): void { $this->federationBackendNotifier = $this->createMock(BackendNotifier::class); $this->time = $this->createMock(ITimeFactory::class); $this->cacheFactory = $this->createMock(ICacheFactory::class); + $this->userStatusManager = $this->createMock(IManager::class); $this->service = new ParticipantService( $this->serverConfig, $this->talkConfig, @@ -85,7 +88,8 @@ public function setUp(): void { $this->membershipService, $this->federationBackendNotifier, $this->time, - $this->cacheFactory + $this->cacheFactory, + $this->userStatusManager, ); }