mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 02:11:45 +01:00
Minor refactoring
This commit is contained in:
@@ -17,7 +17,7 @@ use Meritoo\LimeSurvey\ApiClient\Result\Item\Participant;
|
||||
use Meritoo\LimeSurvey\ApiClient\Result\Item\ParticipantShort;
|
||||
|
||||
/**
|
||||
* Test case of the collection of participants (of surveys)
|
||||
* Test case of the collection of participants' short data
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
@@ -25,7 +25,7 @@ use Meritoo\LimeSurvey\ApiClient\Result\Item\ParticipantShort;
|
||||
class ParticipantsTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* An empty collection of participants (of surveys)
|
||||
* An empty collection of participants' short data
|
||||
*
|
||||
* @var Participants
|
||||
*/
|
||||
|
||||
@@ -127,12 +127,24 @@ class ParticipantShortTest extends BaseTestCase
|
||||
static::assertEquals($participant2->getEmail(), $participantShort2->getEmail());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getParticipantsRawData();
|
||||
|
||||
$this->participant1stInstance = new ParticipantShort($this->rawData[0]);
|
||||
$this->participant2ndInstance = new ParticipantShort($this->rawData[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns raw data of participants
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getParticipantsRawData()
|
||||
private static function getParticipantsRawData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -153,16 +165,4 @@ class ParticipantShortTest extends BaseTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getParticipantsRawData();
|
||||
|
||||
$this->participant1stInstance = new ParticipantShort($this->rawData[0]);
|
||||
$this->participant2ndInstance = new ParticipantShort($this->rawData[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,12 +159,24 @@ class ParticipantTest extends BaseTestCase
|
||||
static::assertNull($this->participant2ndInstance->getValidUntil());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getParticipantsRawData();
|
||||
|
||||
$this->participant1stInstance = new Participant($this->rawData[0]);
|
||||
$this->participant2ndInstance = new Participant($this->rawData[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns raw data of participants
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getParticipantsRawData()
|
||||
private static function getParticipantsRawData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -207,16 +219,4 @@ class ParticipantTest extends BaseTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getParticipantsRawData();
|
||||
|
||||
$this->participant1stInstance = new Participant($this->rawData[0]);
|
||||
$this->participant2ndInstance = new Participant($this->rawData[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,12 +158,24 @@ class QuestionShortTest extends BaseTestCase
|
||||
static::assertEquals('HR', $this->question2ndInstance->getModuleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getQuestionsRawData();
|
||||
|
||||
$this->question1stInstance = new QuestionShort($this->rawData[0]);
|
||||
$this->question2ndInstance = new QuestionShort($this->rawData[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns raw data of questions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getQuestionsRawData()
|
||||
private static function getQuestionsRawData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -214,16 +226,4 @@ class QuestionShortTest extends BaseTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getQuestionsRawData();
|
||||
|
||||
$this->question1stInstance = new QuestionShort($this->rawData[0]);
|
||||
$this->question2ndInstance = new QuestionShort($this->rawData[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,12 +194,24 @@ class QuestionTest extends BaseTestCase
|
||||
static::assertNull($this->question2ndInstance->getDefaultValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getQuestionsRawData();
|
||||
|
||||
$this->question1stInstance = new Question($this->rawData[0]);
|
||||
$this->question2ndInstance = new Question($this->rawData[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns raw data of questions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getQuestionsRawData()
|
||||
private static function getQuestionsRawData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -276,16 +288,4 @@ class QuestionTest extends BaseTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->rawData = static::getQuestionsRawData();
|
||||
|
||||
$this->question1stInstance = new Question($this->rawData[0]);
|
||||
$this->question2ndInstance = new Question($this->rawData[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,13 +183,14 @@ class ParticipantServiceTest extends BaseTestCase
|
||||
$this->createServiceWithoutParticipants($rpcClientManager, $sessionManager);
|
||||
$this->createServiceWithParticipants($rpcClientManager, $sessionManager);
|
||||
|
||||
static::assertNull($this->serviceWithoutParticipants->getParticipant(1, 'john@scott.com'));
|
||||
$participant = $this->serviceWithParticipants->getParticipant(1, 'john@scott.com');
|
||||
$participant1 = $this->serviceWithoutParticipants->getParticipant(1, 'john@scott.com');
|
||||
$participant2 = $this->serviceWithParticipants->getParticipant(1, 'john@scott.com');
|
||||
|
||||
static::assertInstanceOf(ParticipantShort::class, $participant);
|
||||
static::assertEquals('John', $participant->getFirstName());
|
||||
static::assertEquals('Scott', $participant->getLastName());
|
||||
static::assertEquals('john@scott.com', $participant->getEmail());
|
||||
static::assertNull($participant1);
|
||||
static::assertInstanceOf(ParticipantShort::class, $participant2);
|
||||
static::assertEquals('John', $participant2->getFirstName());
|
||||
static::assertEquals('Scott', $participant2->getLastName());
|
||||
static::assertEquals('john@scott.com', $participant2->getEmail());
|
||||
}
|
||||
|
||||
public function testGetParticipantDetails()
|
||||
@@ -212,22 +213,23 @@ class ParticipantServiceTest extends BaseTestCase
|
||||
$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');
|
||||
$participant1 = $this->serviceWithoutParticipants->getParticipantDetails(1, 'john@scott.com');
|
||||
$participant2 = $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());
|
||||
static::assertNull($participant1);
|
||||
static::assertInstanceOf(Participant::class, $participant2);
|
||||
static::assertEquals($runMethodCallResults['tid'], $participant2->getId());
|
||||
static::assertEquals($runMethodCallResults['firstname'], $participant2->getFirstName());
|
||||
static::assertEquals($runMethodCallResults['lastname'], $participant2->getLastName());
|
||||
static::assertEquals($runMethodCallResults['email'], $participant2->getEmail());
|
||||
static::assertEquals($runMethodCallResults['token'], $participant2->getToken());
|
||||
static::assertFalse($participant2->isSent());
|
||||
static::assertFalse($participant2->isCompleted());
|
||||
static::assertNull($participant2->isBlacklisted());
|
||||
static::assertNull($participant2->getValidFrom());
|
||||
}
|
||||
|
||||
public function testHasParticipantFilledSurveyWithException()
|
||||
public function testHasParticipantFilledSurveyWithoutParticipants()
|
||||
{
|
||||
$this->expectException(MissingParticipantOfSurveyException::class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user