diff --git a/src/Meritoo/LimeSurvey/ApiClient/Service/ParticipantService.php b/src/Meritoo/LimeSurvey/ApiClient/Service/ParticipantService.php index be672fa..5908516 100644 --- a/src/Meritoo/LimeSurvey/ApiClient/Service/ParticipantService.php +++ b/src/Meritoo/LimeSurvey/ApiClient/Service/ParticipantService.php @@ -53,6 +53,16 @@ class ParticipantService $this->allParticipants = $allParticipants; } + /** + * Returns client of the LimeSurvey's API + * + * @return Client + */ + public function getClient() + { + return $this->client; + } + /** * Returns participants of given survey * diff --git a/src/Meritoo/LimeSurvey/ApiClient/Service/SurveyService.php b/src/Meritoo/LimeSurvey/ApiClient/Service/SurveyService.php index b5f4e98..ab59713 100644 --- a/src/Meritoo/LimeSurvey/ApiClient/Service/SurveyService.php +++ b/src/Meritoo/LimeSurvey/ApiClient/Service/SurveyService.php @@ -51,6 +51,16 @@ class SurveyService $this->allSurveys = $allSurveys; } + /** + * Returns client of the LimeSurvey's API + * + * @return Client + */ + public function getClient() + { + return $this->client; + } + /** * Returns all surveys * diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/ParticipantServiceTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/ParticipantServiceTest.php index 6606c94..39b3cb9 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/ParticipantServiceTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/ParticipantServiceTest.php @@ -49,6 +49,24 @@ class ParticipantServiceTest extends BaseTestCase static::assertConstructorVisibilityAndArguments(ParticipantService::class, OopVisibilityType::IS_PUBLIC, 2, 1); } + public function testGetClient() + { + $rpcClientManager = $this->getJsonRpcClientManager(0); + $sessionManager = $this->getSessionManager(); + + $this->createServiceWithoutParticipants($rpcClientManager, $sessionManager); + $this->createServiceWithParticipants($rpcClientManager, $sessionManager); + + static::assertInstanceOf(Client::class, $this->serviceWithoutParticipants->getClient()); + static::assertInstanceOf(Client::class, $this->serviceWithParticipants->getClient()); + + $connectionConfiguration = new ConnectionConfiguration('http://test.com', 'test', 'test'); + $client = new Client($connectionConfiguration); + $participantService = new ParticipantService($client); + + static::assertEquals($client, $participantService->getClient()); + } + public function testGetSurveyParticipantsFromEmptyParticipants() { $rpcClientManager = $this->getJsonRpcClientManager(3); diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/SurveyServiceTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/SurveyServiceTest.php index 8f3d427..bcdac6a 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/SurveyServiceTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Service/SurveyServiceTest.php @@ -48,6 +48,24 @@ class SurveyServiceTest extends BaseTestCase static::assertConstructorVisibilityAndArguments(SurveyService::class, OopVisibilityType::IS_PUBLIC, 2, 1); } + public function testGetClient() + { + $rpcClientManager = $this->getJsonRpcClientManager(0); + $sessionManager = $this->getSessionManager(); + + $this->createServiceWithoutSurveys($rpcClientManager, $sessionManager); + $this->createServiceWithSurveys($rpcClientManager, $sessionManager); + + static::assertInstanceOf(Client::class, $this->serviceWithoutSurveys->getClient()); + static::assertInstanceOf(Client::class, $this->serviceWithSurveys->getClient()); + + $connectionConfiguration = new ConnectionConfiguration('http://test.com', 'test', 'test'); + $client = new Client($connectionConfiguration); + $surveyService = new SurveyService($client); + + static::assertEquals($client, $surveyService->getClient()); + } + public function testGetAllSurveys() { $rpcClientManager = $this->getJsonRpcClientManager(1);