ParticipantService & SurveyService - allow to get a client from these services (add getters)

This commit is contained in:
Meritoo
2017-09-28 21:34:31 +02:00
parent f8a675d0fb
commit 0562cb4d21
4 changed files with 56 additions and 0 deletions

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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);

View File

@@ -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);