mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 10:11:49 +01:00
Support PHP 5.4
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
|
||||
namespace Meritoo\LimeSurvey\Test\ApiClient\Exception;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
use Meritoo\LimeSurvey\ApiClient\Exception\CannotProcessDataException;
|
||||
@@ -23,7 +22,7 @@ class CannotProcessDataExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(CannotProcessDataException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(CannotProcessDataException::className, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,12 +40,25 @@ class CannotProcessDataExceptionTest extends BaseTestCase
|
||||
/**
|
||||
* Provides reason why data cannot be processed
|
||||
*
|
||||
* @return Generator
|
||||
* @return array
|
||||
* //return Generator
|
||||
*/
|
||||
public function provideReason()
|
||||
{
|
||||
$template = 'Raw data returned by the LimeSurvey\'s API cannot be processed. Reason: \'%s\'.';
|
||||
|
||||
return [
|
||||
[
|
||||
'unknown',
|
||||
sprintf($template, 'unknown'),
|
||||
],
|
||||
[
|
||||
'Invalid user name or password',
|
||||
sprintf($template, 'Invalid user name or password'),
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
yield[
|
||||
'unknown',
|
||||
sprintf($template, 'unknown'),
|
||||
@@ -56,5 +68,6 @@ class CannotProcessDataExceptionTest extends BaseTestCase
|
||||
'Invalid user name or password',
|
||||
sprintf($template, 'Invalid user name or password'),
|
||||
];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
namespace Meritoo\LimeSurvey\Test\ApiClient\Exception;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
use Meritoo\LimeSurvey\ApiClient\Exception\CreateSessionKeyFailedException;
|
||||
@@ -23,7 +22,7 @@ class CreateSessionKeyFailedExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(CreateSessionKeyFailedException::class, OopVisibilityType::IS_PUBLIC, 1, 0);
|
||||
static::assertConstructorVisibilityAndArguments(CreateSessionKeyFailedException::className, OopVisibilityType::IS_PUBLIC, 1, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,13 +40,26 @@ class CreateSessionKeyFailedExceptionTest extends BaseTestCase
|
||||
/**
|
||||
* Provides reason of failure
|
||||
*
|
||||
* @return Generator
|
||||
* @return array
|
||||
* //return Generator
|
||||
*/
|
||||
public function provideReason()
|
||||
{
|
||||
$shortMessage = 'Create of the session key has failed';
|
||||
$longMessageTemplate = sprintf('%s. Reason: \'%s\'.', $shortMessage, '%s');
|
||||
|
||||
return [
|
||||
[
|
||||
'',
|
||||
$shortMessage,
|
||||
],
|
||||
[
|
||||
'Invalid user name or password',
|
||||
sprintf($longMessageTemplate, 'Invalid user name or password'),
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
yield[
|
||||
'',
|
||||
$shortMessage,
|
||||
@@ -57,5 +69,6 @@ class CreateSessionKeyFailedExceptionTest extends BaseTestCase
|
||||
'Invalid user name or password',
|
||||
sprintf($longMessageTemplate, 'Invalid user name or password'),
|
||||
];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,9 @@
|
||||
|
||||
namespace Meritoo\LimeSurvey\Test\ApiClient\Exception;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
use Meritoo\LimeSurvey\ApiClient\Base\Result\BaseItem;
|
||||
use Meritoo\LimeSurvey\ApiClient\Exception\IncorrectClassOfResultItemException;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Test case of an exception used while class used to create instance of one item of the result is incorrect
|
||||
@@ -25,7 +22,7 @@ class IncorrectClassOfResultItemExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(IncorrectClassOfResultItemException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(IncorrectClassOfResultItemException::className, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,16 +40,26 @@ class IncorrectClassOfResultItemExceptionTest extends BaseTestCase
|
||||
/**
|
||||
* Provides incorrect class name used to create instance of one item
|
||||
*
|
||||
* @return Generator
|
||||
* @return array
|
||||
* //return Generator
|
||||
*/
|
||||
public function provideIncorrectClassName()
|
||||
{
|
||||
$template = 'Class %s used to create instance of one item of the result should extend %s, but it does not. Did'
|
||||
. ' you forget to use proper base class?';
|
||||
|
||||
return [
|
||||
[
|
||||
'\stdClass',
|
||||
sprintf($template, '\stdClass', 'Meritoo\LimeSurvey\ApiClient\Base\Result\BaseItem'),
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
yield[
|
||||
stdClass::class,
|
||||
sprintf($template, stdClass::class, BaseItem::class),
|
||||
];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
namespace Meritoo\LimeSurvey\Test\ApiClient\Exception;
|
||||
|
||||
use Exception;
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
use Meritoo\LimeSurvey\ApiClient\Exception\InvalidResultOfMethodRunException;
|
||||
@@ -25,7 +24,7 @@ class InvalidResultOfMethodRunExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(InvalidResultOfMethodRunException::class, OopVisibilityType::IS_PUBLIC, 3, 2);
|
||||
static::assertConstructorVisibilityAndArguments(InvalidResultOfMethodRunException::className, OopVisibilityType::IS_PUBLIC, 3, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +44,8 @@ class InvalidResultOfMethodRunExceptionTest extends BaseTestCase
|
||||
/**
|
||||
* Provides previous exception, name and arguments of called method
|
||||
*
|
||||
* @return Generator
|
||||
* @return array
|
||||
* //return Generator
|
||||
*/
|
||||
public function providePreviousExceptionAndMethod()
|
||||
{
|
||||
@@ -54,6 +54,26 @@ class InvalidResultOfMethodRunExceptionTest extends BaseTestCase
|
||||
. "- method: %s,\n"
|
||||
. '- arguments: %s.';
|
||||
|
||||
return [
|
||||
[
|
||||
new Exception('Lorem ipsum'),
|
||||
MethodType::ADD_RESPONSE,
|
||||
[],
|
||||
sprintf($template, 'Lorem ipsum', MethodType::ADD_RESPONSE, '(no arguments)'),
|
||||
],
|
||||
[
|
||||
new Exception('Dolor sit amet'),
|
||||
MethodType::LIST_SURVEYS,
|
||||
[
|
||||
'fist_name' => 'John',
|
||||
'last_name' => 'Scott',
|
||||
'email' => 'john@scott.com',
|
||||
],
|
||||
sprintf($template, 'Dolor sit amet', MethodType::LIST_SURVEYS, 'fist_name="John", last_name="Scott", email="john@scott.com"'),
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
yield[
|
||||
new Exception('Lorem ipsum'),
|
||||
MethodType::ADD_RESPONSE,
|
||||
@@ -71,5 +91,6 @@ class InvalidResultOfMethodRunExceptionTest extends BaseTestCase
|
||||
],
|
||||
sprintf($template, 'Dolor sit amet', MethodType::LIST_SURVEYS, 'fist_name="John", last_name="Scott", email="john@scott.com"'),
|
||||
];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class MissingParticipantOfSurveyExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(MissingParticipantOfSurveyException::class, OopVisibilityType::IS_PUBLIC, 2, 2);
|
||||
static::assertConstructorVisibilityAndArguments(MissingParticipantOfSurveyException::className, OopVisibilityType::IS_PUBLIC, 2, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,12 +41,27 @@ class MissingParticipantOfSurveyExceptionTest extends BaseTestCase
|
||||
/**
|
||||
* Provides ID of survey and e-mail address of the participant
|
||||
*
|
||||
* @return Generator
|
||||
* @return array
|
||||
* //return Generator
|
||||
*/
|
||||
public function provideSurveyIdAndEmail()
|
||||
{
|
||||
$template = 'Participant with e-mail %s of survey with ID %s is missing. Maybe was not added to the survey?';
|
||||
|
||||
return [
|
||||
[
|
||||
1,
|
||||
'lorem@ipsum.com',
|
||||
sprintf($template, 'lorem@ipsum.com', 1),
|
||||
],
|
||||
[
|
||||
1234,
|
||||
'another@email.comm',
|
||||
sprintf($template, 'another@email.comm', 1234),
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
yield[
|
||||
1,
|
||||
'lorem@ipsum.com',
|
||||
@@ -58,5 +73,6 @@ class MissingParticipantOfSurveyExceptionTest extends BaseTestCase
|
||||
'another@email.comm',
|
||||
sprintf($template, 'another@email.comm', 1234),
|
||||
];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
|
||||
namespace Meritoo\LimeSurvey\Test\ApiClient\Exception;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
use Meritoo\LimeSurvey\ApiClient\Exception\UnknownInstanceOfResultItem;
|
||||
use Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor;
|
||||
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
|
||||
|
||||
/**
|
||||
@@ -26,7 +24,7 @@ class UnknownInstanceOfResultItemTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(UnknownInstanceOfResultItem::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(UnknownInstanceOfResultItem::className, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,13 +43,26 @@ class UnknownInstanceOfResultItemTest extends BaseTestCase
|
||||
/**
|
||||
* Provides name of called method
|
||||
*
|
||||
* @return Generator
|
||||
* @return array
|
||||
* //return Generator
|
||||
*/
|
||||
public function provideMethodName()
|
||||
{
|
||||
$template = 'Class name used to create instance of one item used by result the of \'%s\' LimeSurvey API\'s'
|
||||
. ' method is unknown. Proper class is not mapped in %s::%s() method. Did you forget about this?';
|
||||
|
||||
return [
|
||||
[
|
||||
MethodType::LIST_SURVEYS,
|
||||
sprintf($template, MethodType::LIST_SURVEYS, 'Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor', 'getItemClassName'),
|
||||
],
|
||||
[
|
||||
MethodType::ADD_PARTICIPANTS,
|
||||
sprintf($template, MethodType::ADD_PARTICIPANTS, 'Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor', 'getItemClassName'),
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
yield[
|
||||
MethodType::LIST_SURVEYS,
|
||||
sprintf($template, MethodType::LIST_SURVEYS, ResultProcessor::class, 'getItemClassName'),
|
||||
@@ -61,5 +72,6 @@ class UnknownInstanceOfResultItemTest extends BaseTestCase
|
||||
MethodType::ADD_PARTICIPANTS,
|
||||
sprintf($template, MethodType::ADD_PARTICIPANTS, ResultProcessor::class, 'getItemClassName'),
|
||||
];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
namespace Meritoo\LimeSurvey\Test\ApiClient\Exception;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
use Meritoo\LimeSurvey\ApiClient\Exception\UnknownMethodException;
|
||||
@@ -24,7 +23,7 @@ class UnknownMethodExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(UnknownMethodException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(UnknownMethodException::className, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +41,8 @@ class UnknownMethodExceptionTest extends BaseTestCase
|
||||
/**
|
||||
* Provides name of called method
|
||||
*
|
||||
* @return Generator
|
||||
* @return array
|
||||
* //return Generator
|
||||
*/
|
||||
public function provideUnknownType()
|
||||
{
|
||||
@@ -51,6 +51,18 @@ class UnknownMethodExceptionTest extends BaseTestCase
|
||||
$template = 'The \'%s\' type of name of method used while talking to the LimeSurvey\'s API is unknown. Probably'
|
||||
. ' doesn\'t exist or there is a typo. You should use one of these types: %s.';
|
||||
|
||||
return [
|
||||
[
|
||||
MethodType::ADD_PARTICIPANTS,
|
||||
sprintf($template, MethodType::ADD_PARTICIPANTS, $allMethods),
|
||||
],
|
||||
[
|
||||
MethodType::ADD_PARTICIPANTS,
|
||||
sprintf($template, MethodType::ADD_PARTICIPANTS, $allMethods),
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
yield[
|
||||
MethodType::ADD_PARTICIPANTS,
|
||||
sprintf($template, MethodType::ADD_PARTICIPANTS, $allMethods),
|
||||
@@ -60,5 +72,6 @@ class UnknownMethodExceptionTest extends BaseTestCase
|
||||
MethodType::ADD_PARTICIPANTS,
|
||||
sprintf($template, MethodType::ADD_PARTICIPANTS, $allMethods),
|
||||
];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user