From d0badf1ec618eb1ac30d0236baaca45f76304194 Mon Sep 17 00:00:00 2001 From: Meritoo Date: Fri, 22 Sep 2017 19:22:08 +0200 Subject: [PATCH] Tests - implement BaseTestCase::assert*() methods to verify constructors --- src/Meritoo/LimeSurvey/ApiClient/Client/Client.php | 2 +- .../Test/ApiClient/Base/Result/BaseItemTest.php | 6 +----- .../LimeSurvey/Test/ApiClient/Client/ClientTest.php | 5 +++++ .../Configuration/ConnectionConfigurationTest.php | 6 ++++++ .../Test/ApiClient/Result/Item/ParticipantShortTest.php | 9 +++++++-- .../Test/ApiClient/Result/Item/ParticipantTest.php | 9 +++++++-- .../Test/ApiClient/Result/Item/QuestionShortTest.php | 5 +++++ .../Test/ApiClient/Result/Item/QuestionTest.php | 9 +++++++-- .../LimeSurvey/Test/ApiClient/Result/Item/SurveyTest.php | 9 +++++++-- .../ApiClient/Result/Processor/ResultProcessorTest.php | 6 +----- .../LimeSurvey/Test/ApiClient/Type/MethodTypeTest.php | 5 +++++ .../Test/ApiClient/Type/SystemMethodTypeTest.php | 5 +++++ 12 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/Meritoo/LimeSurvey/ApiClient/Client/Client.php b/src/Meritoo/LimeSurvey/ApiClient/Client/Client.php index dcb97ad..5a5e77a 100644 --- a/src/Meritoo/LimeSurvey/ApiClient/Client/Client.php +++ b/src/Meritoo/LimeSurvey/ApiClient/Client/Client.php @@ -92,7 +92,7 @@ class Client ->getSessionKey($username, $password); /* - * Use the session's key as of the method's arguments + * Use the session's key as one of the method's arguments */ array_unshift($arguments, $sessionKey); diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Base/Result/BaseItemTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Base/Result/BaseItemTest.php index c00d1b1..299209c 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Base/Result/BaseItemTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Base/Result/BaseItemTest.php @@ -10,7 +10,6 @@ namespace Meritoo\LimeSurvey\Test\ApiClient\Base\Result; use Meritoo\Common\Test\Base\BaseTestCase; use Meritoo\LimeSurvey\ApiClient\Base\Result\BaseItem; -use ReflectionClass; /** * Test case of the base class for one item of result/data fetched while talking to the LimeSurvey's API @@ -22,10 +21,7 @@ class BaseItemTest extends BaseTestCase { public function testConstructorVisibilityAndArguments() { - $reflection = new ReflectionClass(BaseItem::class); - $constructor = $reflection->getConstructor(); - - static::assertNull($constructor); + static::assertHasNoConstructor(BaseItem::class); } public function testSetValues() diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Client/ClientTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Client/ClientTest.php index 15ba693..fa362ea 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Client/ClientTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Client/ClientTest.php @@ -34,6 +34,11 @@ class ClientTest extends BaseTestCase */ private $configuration; + public function testConstructorVisibilityAndArguments() + { + static::assertConstructorVisibilityAndArguments(Client::class, OopVisibilityType::IS_PUBLIC, 3, 1); + } + /** * @param string $incorrectMethod Incorrect name of method to call * @dataProvider provideIncorrectMethod diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Configuration/ConnectionConfigurationTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Configuration/ConnectionConfigurationTest.php index 92fb9f1..d782bab 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Configuration/ConnectionConfigurationTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Configuration/ConnectionConfigurationTest.php @@ -11,6 +11,7 @@ namespace Meritoo\LimeSurvey\Test\ApiClient\Configuration; use Generator; use Meritoo\Common\Exception\Regex\InvalidUrlException; use Meritoo\Common\Test\Base\BaseTestCase; +use Meritoo\Common\Type\OopVisibilityType; use Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration; /** @@ -21,6 +22,11 @@ use Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration; */ class ConnectionConfigurationTest extends BaseTestCase { + public function testConstructorVisibilityAndArguments() + { + static::assertConstructorVisibilityAndArguments(ConnectionConfiguration::class, OopVisibilityType::IS_PUBLIC, 4, 3); + } + /** * @param mixed $emptyBaseUrl Empty base url * @dataProvider provideEmptyBaseUrl diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantShortTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantShortTest.php index ee3f044..80a2c75 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantShortTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantShortTest.php @@ -8,10 +8,10 @@ namespace Meritoo\LimeSurvey\Test\ApiClient\Result\Item; +use Meritoo\Common\Test\Base\BaseTestCase; use Meritoo\LimeSurvey\ApiClient\Result\Item\ParticipantShort; use Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor; use Meritoo\LimeSurvey\ApiClient\Type\MethodType; -use PHPUnit_Framework_TestCase; /** * Test case of the one item of the result/data: short data of participant @@ -19,7 +19,7 @@ use PHPUnit_Framework_TestCase; * @author Krzysztof Niziol * @copyright Meritoo.pl */ -class ParticipantShortTest extends PHPUnit_Framework_TestCase +class ParticipantShortTest extends BaseTestCase { /** * Raw data of participants @@ -42,6 +42,11 @@ class ParticipantShortTest extends PHPUnit_Framework_TestCase */ private $participant2ndInstance; + public function testConstructorVisibilityAndArguments() + { + static::assertHasNoConstructor(ParticipantShort::class); + } + public function testCreateOfTheParticipant() { $processor = new ResultProcessor(); diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantTest.php index e604ac0..7531cf8 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/ParticipantTest.php @@ -9,10 +9,10 @@ namespace Meritoo\LimeSurvey\Test\ApiClient\Result\Item; use DateTime; +use Meritoo\Common\Test\Base\BaseTestCase; use Meritoo\LimeSurvey\ApiClient\Result\Item\Participant; use Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor; use Meritoo\LimeSurvey\ApiClient\Type\MethodType; -use PHPUnit_Framework_TestCase; /** * Test case of the one item of the result/data: full data of participant @@ -20,7 +20,7 @@ use PHPUnit_Framework_TestCase; * @author Krzysztof Niziol * @copyright Meritoo.pl */ -class ParticipantTest extends PHPUnit_Framework_TestCase +class ParticipantTest extends BaseTestCase { /** * Raw data of participants @@ -43,6 +43,11 @@ class ParticipantTest extends PHPUnit_Framework_TestCase */ private $participant2ndInstance; + public function testConstructorVisibilityAndArguments() + { + static::assertHasNoConstructor(Participant::class); + } + public function testCreateOfTheParticipant() { $processor = new ResultProcessor(); diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionShortTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionShortTest.php index 73c50d9..2843627 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionShortTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionShortTest.php @@ -42,6 +42,11 @@ class QuestionShortTest extends BaseTestCase */ private $question2ndInstance; + public function testConstructorVisibilityAndArguments() + { + static::assertHasNoConstructor(QuestionShort::class); + } + public function testCreateOfTheQuestionShort() { $processor = new ResultProcessor(); diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionTest.php index 4485331..a03f965 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/QuestionTest.php @@ -8,10 +8,10 @@ namespace Meritoo\LimeSurvey\Test\ApiClient\Result\Item; +use Meritoo\Common\Test\Base\BaseTestCase; use Meritoo\LimeSurvey\ApiClient\Result\Item\Question; use Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor; use Meritoo\LimeSurvey\ApiClient\Type\MethodType; -use PHPUnit_Framework_TestCase; /** * Test case of the one item of the result/data: full data of one question of survey @@ -19,7 +19,7 @@ use PHPUnit_Framework_TestCase; * @author Krzysztof Niziol * @copyright Meritoo.pl */ -class QuestionTest extends PHPUnit_Framework_TestCase +class QuestionTest extends BaseTestCase { /** * Raw data of questions @@ -42,6 +42,11 @@ class QuestionTest extends PHPUnit_Framework_TestCase */ private $question2ndInstance; + public function testConstructorVisibilityAndArguments() + { + static::assertHasNoConstructor(Question::class); + } + public function testCreateOfTheQuestionShort() { $processor = new ResultProcessor(); diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/SurveyTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/SurveyTest.php index aa14ce3..cb84ff6 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/SurveyTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Item/SurveyTest.php @@ -9,10 +9,10 @@ namespace Meritoo\LimeSurvey\Test\ApiClient\Result\Item; use DateTime; +use Meritoo\Common\Test\Base\BaseTestCase; use Meritoo\LimeSurvey\ApiClient\Result\Item\Survey; use Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor; use Meritoo\LimeSurvey\ApiClient\Type\MethodType; -use PHPUnit_Framework_TestCase; /** * Test case of the one item of the result/data: survey @@ -20,7 +20,7 @@ use PHPUnit_Framework_TestCase; * @author Krzysztof Niziol * @copyright Meritoo.pl */ -class SurveyTest extends PHPUnit_Framework_TestCase +class SurveyTest extends BaseTestCase { /** * Raw data of surveys @@ -43,6 +43,11 @@ class SurveyTest extends PHPUnit_Framework_TestCase */ private $survey2ndInstance; + public function testConstructorVisibilityAndArguments() + { + static::assertHasNoConstructor(Survey::class); + } + public function testCreateOfTheSurvey() { $processor = new ResultProcessor(); diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Processor/ResultProcessorTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Processor/ResultProcessorTest.php index 8d7f24d..e52c0a2 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Processor/ResultProcessorTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Result/Processor/ResultProcessorTest.php @@ -15,7 +15,6 @@ use Meritoo\LimeSurvey\ApiClient\Exception\UnknownInstanceOfResultItem; use Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor; use Meritoo\LimeSurvey\ApiClient\Type\MethodType; use Meritoo\LimeSurvey\Test\ApiClient\Result\Item\SurveyTest; -use ReflectionClass; /** * Test case of the processor of the raw data fetched while talking to the LimeSurvey's API @@ -27,10 +26,7 @@ class ResultProcessorTest extends BaseTestCase { public function testConstructorVisibilityAndArguments() { - $reflection = new ReflectionClass(ResultProcessor::class); - $constructor = $reflection->getConstructor(); - - static::assertNull($constructor); + static::assertHasNoConstructor(ResultProcessor::class); } public function testProcessWithEmptyRawData() diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/MethodTypeTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/MethodTypeTest.php index b9e3c14..4def3cc 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/MethodTypeTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/MethodTypeTest.php @@ -21,6 +21,11 @@ use Meritoo\LimeSurvey\ApiClient\Type\MethodType; */ class MethodTypeTest extends BaseTypeTestCase { + public function testConstructorVisibilityAndArguments() + { + static::assertHasNoConstructor(MethodType::class); + } + /** * @param string $incorrectMethod Type of method to verify * @dataProvider provideIncorrectMethod diff --git a/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/SystemMethodTypeTest.php b/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/SystemMethodTypeTest.php index 03464e6..779c10c 100644 --- a/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/SystemMethodTypeTest.php +++ b/tests/Meritoo/LimeSurvey/Test/ApiClient/Type/SystemMethodTypeTest.php @@ -19,6 +19,11 @@ use Meritoo\LimeSurvey\ApiClient\Type\SystemMethodType; */ class SystemMethodTypeTest extends BaseTypeTestCase { + public function testConstructorVisibilityAndArguments() + { + static::assertHasNoConstructor(SystemMethodType::class); + } + /** * {@inheritdoc} */