Tests - implement BaseTestCase::assert*() methods to verify constructors

This commit is contained in:
Meritoo
2017-09-22 19:22:08 +02:00
parent 2dc215a3e4
commit d0badf1ec6
12 changed files with 57 additions and 19 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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 <krzysztof.niziol@meritoo.pl>
* @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();

View File

@@ -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 <krzysztof.niziol@meritoo.pl>
* @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();

View File

@@ -42,6 +42,11 @@ class QuestionShortTest extends BaseTestCase
*/
private $question2ndInstance;
public function testConstructorVisibilityAndArguments()
{
static::assertHasNoConstructor(QuestionShort::class);
}
public function testCreateOfTheQuestionShort()
{
$processor = new ResultProcessor();

View File

@@ -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 <krzysztof.niziol@meritoo.pl>
* @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();

View File

@@ -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 <krzysztof.niziol@meritoo.pl>
* @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();

View File

@@ -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()

View File

@@ -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

View File

@@ -19,6 +19,11 @@ use Meritoo\LimeSurvey\ApiClient\Type\SystemMethodType;
*/
class SystemMethodTypeTest extends BaseTypeTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertHasNoConstructor(SystemMethodType::class);
}
/**
* {@inheritdoc}
*/