mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 02:11:45 +01:00
ParticipantService - getParticipantDetails() method - returns full data of participant with given e-mail of given survey
This commit is contained in:
@@ -179,7 +179,7 @@ class ParticipantService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns participant with given e-mail of given survey
|
* Returns short data of one participant with given e-mail of given survey
|
||||||
*
|
*
|
||||||
* @param int $surveyId ID of survey
|
* @param int $surveyId ID of survey
|
||||||
* @param string $email E-mail address of the participant
|
* @param string $email E-mail address of the participant
|
||||||
@@ -197,6 +197,31 @@ class ParticipantService
|
|||||||
->getParticipantOfSurvey($surveyId, $email);
|
->getParticipantOfSurvey($surveyId, $email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns full data of participant with given e-mail of given survey
|
||||||
|
*
|
||||||
|
* @param int $surveyId ID of survey
|
||||||
|
* @param string $email E-mail address of the participant
|
||||||
|
* @return Participant|null
|
||||||
|
*/
|
||||||
|
public function getParticipantDetails($surveyId, $email)
|
||||||
|
{
|
||||||
|
$arguments = [
|
||||||
|
$surveyId,
|
||||||
|
[
|
||||||
|
'email' => $email,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$participant = $this
|
||||||
|
->client
|
||||||
|
->run(MethodType::GET_PARTICIPANT_PROPERTIES, $arguments)
|
||||||
|
->getData();
|
||||||
|
|
||||||
|
/* @var Participant $participant */
|
||||||
|
return $participant;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information if participant with given e-mail has filled given survey
|
* Returns information if participant with given e-mail has filled given survey
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -192,6 +192,41 @@ class ParticipantServiceTest extends BaseTestCase
|
|||||||
static::assertEquals('john@scott.com', $participant->getEmail());
|
static::assertEquals('john@scott.com', $participant->getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetParticipantDetails()
|
||||||
|
{
|
||||||
|
$sessionManager = $this->getSessionManager();
|
||||||
|
|
||||||
|
$rpcClientManager = $this->getJsonRpcClientManager(1);
|
||||||
|
$this->createServiceWithoutParticipants($rpcClientManager, $sessionManager);
|
||||||
|
|
||||||
|
$runMethodCallResults = [
|
||||||
|
'tid' => 1,
|
||||||
|
'firstname' => 'John',
|
||||||
|
'lastname' => 'Scott',
|
||||||
|
'email' => 'john@scott.com',
|
||||||
|
'token' => uniqid(),
|
||||||
|
'sent' => 'N',
|
||||||
|
'completed' => 'N',
|
||||||
|
];
|
||||||
|
|
||||||
|
$rpcClientManager = $this->getJsonRpcClientManager(1, $runMethodCallResults);
|
||||||
|
$this->createServiceWithParticipants($rpcClientManager, $sessionManager);
|
||||||
|
|
||||||
|
static::assertNull($this->serviceWithoutParticipants->getParticipantDetails(1, 'john@scott.com'));
|
||||||
|
$participant = $this->serviceWithParticipants->getParticipantDetails(1, 'john@scott.com');
|
||||||
|
|
||||||
|
static::assertInstanceOf(Participant::class, $participant);
|
||||||
|
static::assertEquals($runMethodCallResults['tid'], $participant->getId());
|
||||||
|
static::assertEquals($runMethodCallResults['firstname'], $participant->getFirstName());
|
||||||
|
static::assertEquals($runMethodCallResults['lastname'], $participant->getLastName());
|
||||||
|
static::assertEquals($runMethodCallResults['email'], $participant->getEmail());
|
||||||
|
static::assertEquals($runMethodCallResults['token'], $participant->getToken());
|
||||||
|
static::assertFalse($participant->isSent());
|
||||||
|
static::assertFalse($participant->isCompleted());
|
||||||
|
static::assertNull($participant->isBlacklisted());
|
||||||
|
static::assertNull($participant->getValidFrom());
|
||||||
|
}
|
||||||
|
|
||||||
public function testHasParticipantFilledSurveyWithException()
|
public function testHasParticipantFilledSurveyWithException()
|
||||||
{
|
{
|
||||||
$this->expectException(MissingParticipantOfSurveyException::class);
|
$this->expectException(MissingParticipantOfSurveyException::class);
|
||||||
|
|||||||
Reference in New Issue
Block a user