diff --git a/src/LimeSurvey/Result/Collection/Participants.php b/src/LimeSurvey/Result/Collection/Participants.php index cee2244..ff7eaa6 100644 --- a/src/LimeSurvey/Result/Collection/Participants.php +++ b/src/LimeSurvey/Result/Collection/Participants.php @@ -13,7 +13,7 @@ use Meritoo\Common\Exception\Method\DisabledMethodException; use Meritoo\LimeSurvey\ApiClient\Result\Item\ParticipantShort; /** - * Collection of participants (of surveys). + * Collection of participants' short data. * All participants grouped per survey. * * It's a collection of participants' collections. diff --git a/src/LimeSurvey/Service/ParticipantService.php b/src/LimeSurvey/Service/ParticipantService.php index 64a11b7..6a1c0f6 100644 --- a/src/LimeSurvey/Service/ParticipantService.php +++ b/src/LimeSurvey/Service/ParticipantService.php @@ -36,7 +36,7 @@ class ParticipantService private $client; /** - * Collection of participants (of surveys). + * Collection of participants' short data. * All participants grouped per survey. * * @var Participants @@ -47,7 +47,7 @@ class ParticipantService * Class constructor * * @param Client $client Client of the LimeSurvey's API - * @param Participants $allParticipants (optional) Collection of participants (of surveys). All participants + * @param Participants $allParticipants (optional) Collection of participants' short data. All participants * grouped per survey. */ public function __construct(Client $client, Participants $allParticipants = null) @@ -181,7 +181,7 @@ class ParticipantService } /** - * Returns short data of one participant with given e-mail of given survey + * Returns short data of one participant with given e-mail (participant of given survey) * * @param int $surveyId ID of survey * @param string $email E-mail address of the participant @@ -200,7 +200,7 @@ class ParticipantService } /** - * Returns full data of participant with given e-mail of given survey + * Returns full data of participant with given e-mail (participant of given survey) * * @param int $surveyId ID of survey * @param string $email E-mail address of the participant diff --git a/tests/Result/Collection/ParticipantsTest.php b/tests/Result/Collection/ParticipantsTest.php index a4adc89..fc23366 100644 --- a/tests/Result/Collection/ParticipantsTest.php +++ b/tests/Result/Collection/ParticipantsTest.php @@ -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 * @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 */ diff --git a/tests/Result/Item/ParticipantShortTest.php b/tests/Result/Item/ParticipantShortTest.php index 1f34fb0..eec8377 100644 --- a/tests/Result/Item/ParticipantShortTest.php +++ b/tests/Result/Item/ParticipantShortTest.php @@ -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]); - } } diff --git a/tests/Result/Item/ParticipantTest.php b/tests/Result/Item/ParticipantTest.php index 3ce6993..fbb4c74 100644 --- a/tests/Result/Item/ParticipantTest.php +++ b/tests/Result/Item/ParticipantTest.php @@ -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]); - } } diff --git a/tests/Result/Item/QuestionShortTest.php b/tests/Result/Item/QuestionShortTest.php index c431767..dcd8476 100644 --- a/tests/Result/Item/QuestionShortTest.php +++ b/tests/Result/Item/QuestionShortTest.php @@ -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]); - } } diff --git a/tests/Result/Item/QuestionTest.php b/tests/Result/Item/QuestionTest.php index 1dd161c..a905f8d 100644 --- a/tests/Result/Item/QuestionTest.php +++ b/tests/Result/Item/QuestionTest.php @@ -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]); - } } diff --git a/tests/Service/ParticipantServiceTest.php b/tests/Service/ParticipantServiceTest.php index 7853652..26e0e48 100644 --- a/tests/Service/ParticipantServiceTest.php +++ b/tests/Service/ParticipantServiceTest.php @@ -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::className, $participant); - static::assertEquals('John', $participant->getFirstName()); - static::assertEquals('Scott', $participant->getLastName()); - static::assertEquals('john@scott.com', $participant->getEmail()); + static::assertNull($participant1); + static::assertInstanceOf(ParticipantShort::className, $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::className, $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::className, $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->setExpectedException(MissingParticipantOfSurveyException::className);