mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 10:11:49 +01:00
Tests - add missing tests of Participants::addParticipant() method
This commit is contained in:
@@ -67,7 +67,7 @@ class ParticipantsTest extends BaseTestCase
|
|||||||
(new Participants())->has(new Participant());
|
(new Participants())->has(new Participant());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddParticipantsWithoutParticipants()
|
public function testAddParticipantsUsingEmptyCollection()
|
||||||
{
|
{
|
||||||
$surveyId = 1;
|
$surveyId = 1;
|
||||||
|
|
||||||
@@ -121,6 +121,53 @@ class ParticipantsTest extends BaseTestCase
|
|||||||
static::assertCount(2, $this->participantsOfOneSurvey->getBySurvey($surveyId));
|
static::assertCount(2, $this->participantsOfOneSurvey->getBySurvey($surveyId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAddParticipantFirstParticipant()
|
||||||
|
{
|
||||||
|
$surveyId = 1;
|
||||||
|
$email = 'john@scott.com';
|
||||||
|
$participant = new Participant();
|
||||||
|
|
||||||
|
$participant->setValues([
|
||||||
|
'firstname' => 'John',
|
||||||
|
'lastname' => 'Scott',
|
||||||
|
'email' => $email,
|
||||||
|
'completed' => 'Y',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$participants = new Participants();
|
||||||
|
$result = $participants->addParticipant($participant, $surveyId);
|
||||||
|
|
||||||
|
static::assertEquals($participants, $result);
|
||||||
|
static::assertEquals($participant, $participants->getParticipantOfSurvey($surveyId, $email));
|
||||||
|
|
||||||
|
static::assertTrue($participants->hasParticipantsOfSurvey($surveyId));
|
||||||
|
static::assertFalse($participants->hasParticipantsOfSurvey(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddParticipantNotFirstParticipant()
|
||||||
|
{
|
||||||
|
$surveyId = 1;
|
||||||
|
$email = 'john@scott.com';
|
||||||
|
$participant = new Participant();
|
||||||
|
|
||||||
|
$participant->setValues([
|
||||||
|
'firstname' => 'John',
|
||||||
|
'lastname' => 'Scott',
|
||||||
|
'email' => $email,
|
||||||
|
'completed' => 'Y',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$result = $this
|
||||||
|
->participantsOfOneSurvey
|
||||||
|
->addParticipant($participant, $surveyId);
|
||||||
|
|
||||||
|
static::assertEquals($this->participantsOfOneSurvey, $result);
|
||||||
|
static::assertEquals($participant, $this->participantsOfOneSurvey->getParticipantOfSurvey($surveyId, $email));
|
||||||
|
|
||||||
|
static::assertTrue($this->participantsOfOneSurvey->hasParticipantsOfSurvey($surveyId));
|
||||||
|
static::assertFalse($this->participantsOfOneSurvey->hasParticipantsOfSurvey(2));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user