Support PHP 5.4

This commit is contained in:
Meritoo
2017-10-19 22:00:09 +02:00
parent 835c4325b8
commit bdbaebb5c0
81 changed files with 7268 additions and 135 deletions

View File

@@ -22,11 +22,11 @@ class BaseItemTest extends BaseTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(BaseItem::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(BaseItem::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testSetValuesVisibilityAndArguments()
{
static::assertMethodVisibilityAndArguments(BaseItem::class, 'setValues', OopVisibilityType::IS_PRIVATE, 1, 1);
static::assertMethodVisibilityAndArguments(BaseItem::className, 'setValues', OopVisibilityType::IS_PRIVATE, 1, 1);
}
}

View File

@@ -8,15 +8,12 @@
namespace Meritoo\LimeSurvey\Test\ApiClient\Client;
use Generator;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;
use Meritoo\LimeSurvey\ApiClient\Client\Client;
use Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration;
use Meritoo\LimeSurvey\ApiClient\Exception\UnknownMethodException;
use Meritoo\LimeSurvey\ApiClient\Manager\JsonRpcClientManager;
use Meritoo\LimeSurvey\ApiClient\Manager\SessionManager;
use Meritoo\LimeSurvey\ApiClient\Result\Result;
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
/**
@@ -36,7 +33,7 @@ class ClientTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(Client::class, OopVisibilityType::IS_PUBLIC, 3, 1);
static::assertConstructorVisibilityAndArguments(Client::className, OopVisibilityType::IS_PUBLIC, 3, 1);
}
/**
@@ -45,7 +42,7 @@ class ClientTest extends BaseTestCase
*/
public function testRunWithIncorrectMethod($incorrectMethod)
{
$this->expectException(UnknownMethodException::class);
$this->setExpectedException('Meritoo\LimeSurvey\ApiClient\Exception\UnknownMethodException');
$client = new Client($this->configuration);
$client->run($incorrectMethod);
@@ -61,8 +58,8 @@ class ClientTest extends BaseTestCase
*/
public function testRun($method, $arguments, $debugMode, $expectedRawData)
{
$sessionManager = $this->createMock(SessionManager::class);
$rpcClientManager = $this->createMock(JsonRpcClientManager::class);
$sessionManager = $this->createMock(SessionManager::className);
$rpcClientManager = $this->createMock(JsonRpcClientManager::className);
$rpcClientManager
->expects(static::any())
@@ -78,7 +75,7 @@ class ClientTest extends BaseTestCase
);
$client = new Client($configuration, $rpcClientManager, $sessionManager);
static::assertInstanceOf(Result::class, $client->run($method, $arguments));
static::assertInstanceOf('Meritoo\LimeSurvey\ApiClient\Result\Result', $client->run($method, $arguments));
}
public function testGetConfiguration()
@@ -89,21 +86,29 @@ class ClientTest extends BaseTestCase
public function testGetRpcClientManagerVisibilityAndArguments()
{
static::assertMethodVisibilityAndArguments(Client::class, 'getRpcClientManager', OopVisibilityType::IS_PRIVATE);
static::assertMethodVisibilityAndArguments(Client::className, 'getRpcClientManager', OopVisibilityType::IS_PRIVATE);
}
public function testGetSessionManagerVisibilityAndArguments()
{
static::assertMethodVisibilityAndArguments(Client::class, 'getRpcClientManager', OopVisibilityType::IS_PRIVATE);
static::assertMethodVisibilityAndArguments(Client::className, 'getRpcClientManager', OopVisibilityType::IS_PRIVATE);
}
/**
* Provides incorrect name of method
*
* @return Generator
* @return array
* //return Generator
*/
public function provideIncorrectMethod()
{
return [
['lorem'],
['ipsum'],
[''],
];
/*
yield[
'lorem',
];
@@ -115,15 +120,39 @@ class ClientTest extends BaseTestCase
yield[
'',
];
*/
}
/**
* Provides correct name of method
*
* @return Generator
* @return array
* //return Generator
*/
public function provideMethod()
{
return [
[
MethodType::GET_PARTICIPANT_PROPERTIES,
[],
true,
[],
],
[
MethodType::LIST_SURVEYS,
[],
false,
[],
],
[
MethodType::LIST_PARTICIPANTS,
[],
false,
null,
],
];
/*
yield[
MethodType::GET_PARTICIPANT_PROPERTIES,
[],
@@ -144,6 +173,7 @@ class ClientTest extends BaseTestCase
false,
null,
];
*/
/*
* todo: Use/Verify other types of methods

View File

@@ -8,7 +8,6 @@
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;
@@ -38,7 +37,7 @@ class ConnectionConfigurationTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(ConnectionConfiguration::class, OopVisibilityType::IS_PUBLIC, 5, 3);
static::assertConstructorVisibilityAndArguments(ConnectionConfiguration::className, OopVisibilityType::IS_PUBLIC, 5, 3);
}
/**
@@ -47,7 +46,7 @@ class ConnectionConfigurationTest extends BaseTestCase
*/
public function testConstructorWithEmptyBaseUrl($emptyBaseUrl)
{
$this->expectException(InvalidUrlException::class);
$this->setExpectedException(InvalidUrlException::className);
new ConnectionConfiguration($emptyBaseUrl, '', '');
}
@@ -57,7 +56,7 @@ class ConnectionConfigurationTest extends BaseTestCase
*/
public function testConstructorWithInvalidBaseUrl($invalidBaseUrl)
{
$this->expectException(InvalidUrlException::class);
$this->setExpectedException(InvalidUrlException::className);
new ConnectionConfiguration($invalidBaseUrl, '', '');
}
@@ -94,10 +93,17 @@ class ConnectionConfigurationTest extends BaseTestCase
/**
* Provides empty base url
*
* @return Generator
* @return array
* //return Generator
*/
public function provideEmptyBaseUrl()
{
return [
[''],
[null],
];
/*
yield[
'',
];
@@ -105,15 +111,24 @@ class ConnectionConfigurationTest extends BaseTestCase
yield[
null,
];
*/
}
/**
* Provides invalid base url
*
* @return Generator
* @return array
* //return Generator
*/
public function provideInvalidBaseUrl()
{
return [
['lorem'],
['ipsum'],
['htp:/dolor.com'],
];
/*
yield[
'lorem',
];
@@ -125,6 +140,7 @@ class ConnectionConfigurationTest extends BaseTestCase
yield[
'htp:/dolor.com',
];
*/
}
/**

View File

@@ -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'),
];
*/
}
}

View File

@@ -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'),
];
*/
}
}

View File

@@ -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),
];
*/
}
}

View File

@@ -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"'),
];
*/
}
}

View File

@@ -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),
];
*/
}
}

View File

@@ -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'),
];
*/
}
}

View File

@@ -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),
];
*/
}
}

View File

@@ -8,7 +8,6 @@
namespace Meritoo\LimeSurvey\Test\ApiClient\Manager;
use JsonRPC\Client as RpcClient;
use JsonRPC\Exception\InvalidJsonFormatException;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;
@@ -35,15 +34,15 @@ class JsonRpcClientManagerTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(JsonRpcClientManager::class, OopVisibilityType::IS_PUBLIC, 1, 1);
static::assertConstructorVisibilityAndArguments(JsonRpcClientManager::className, OopVisibilityType::IS_PUBLIC, 1, 1);
}
public function testRunMethodWithEmptyArrayReturned()
{
$rpcClient = $this->createMock(RpcClient::class);
$rpcClient = $this->createMock('\JsonRPC\Client');
$manager = $this
->getMockBuilder(JsonRpcClientManager::class)
->getMockBuilder(JsonRpcClientManager::className)
->setConstructorArgs([
$this->configuration,
])
@@ -68,8 +67,8 @@ class JsonRpcClientManagerTest extends BaseTestCase
public function testRunMethodWithRawDataReturned()
{
$rpcClient = $this->createMock(RpcClient::class);
$manager = $this->createPartialMock(JsonRpcClientManager::class, ['getRpcClient']);
$rpcClient = $this->createMock('\JsonRPC\Client');
$manager = $this->getMock(JsonRpcClientManager::className, ['getRpcClient'], [], '', false);
$rpcClient
->expects(static::once())
@@ -87,10 +86,10 @@ class JsonRpcClientManagerTest extends BaseTestCase
public function testRunMethodWithException()
{
$this->expectException(InvalidResultOfMethodRunException::class);
$this->setExpectedException(InvalidResultOfMethodRunException::className);
$manager = $this->createPartialMock(JsonRpcClientManager::class, ['getRpcClient']);
$rpcClient = $this->createMock(RpcClient::class);
$manager = $this->getMock(JsonRpcClientManager::className, ['getRpcClient'], [], '', false);
$rpcClient = $this->createMock('\JsonRPC\Client');
$rpcClient
->expects(self::once())
@@ -108,7 +107,7 @@ class JsonRpcClientManagerTest extends BaseTestCase
public function testGetRpcClientVisibilityAndArguments()
{
static::assertMethodVisibilityAndArguments(JsonRpcClientManager::class, 'getRpcClient', OopVisibilityType::IS_PROTECTED);
static::assertMethodVisibilityAndArguments(JsonRpcClientManager::className, 'getRpcClient', OopVisibilityType::IS_PROTECTED);
}
/**

View File

@@ -24,15 +24,15 @@ class SessionManagerTest extends BaseTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(SessionManager::class, OopVisibilityType::IS_PUBLIC, 1, 1);
static::assertConstructorVisibilityAndArguments(SessionManager::className, OopVisibilityType::IS_PUBLIC, 1, 1);
}
public function testGetSessionKeyWhenFailedWithoutReason()
{
$this->expectException(CreateSessionKeyFailedException::class);
$this->expectExceptionMessage('Create of the session key has failed');
$this->setExpectedException(CreateSessionKeyFailedException::className, 'Create of the session key has failed');
//$this->expectExceptionMessage('Create of the session key has failed');
$clientManager = $this->createMock(JsonRpcClientManager::class);
$clientManager = $this->createMock(JsonRpcClientManager::className);
$clientManager
->expects(static::any())
@@ -46,10 +46,10 @@ class SessionManagerTest extends BaseTestCase
{
$reason = 'Invalid credentials';
$this->expectException(CreateSessionKeyFailedException::class);
$this->expectExceptionMessage(sprintf('Create of the session key has failed. Reason: \'%s\'.', $reason));
$this->setExpectedException(CreateSessionKeyFailedException::className, sprintf('Create of the session key has failed. Reason: \'%s\'.', $reason));
//$this->expectExceptionMessage(sprintf('Create of the session key has failed. Reason: \'%s\'.', $reason));
$clientManager = $this->createMock(JsonRpcClientManager::class);
$clientManager = $this->createMock(JsonRpcClientManager::className);
$clientManager
->expects(static::any())
@@ -63,7 +63,7 @@ class SessionManagerTest extends BaseTestCase
public function testGetSessionKey()
{
$clientManager = $this->createMock(JsonRpcClientManager::class);
$clientManager = $this->createMock(JsonRpcClientManager::className);
$clientManager
->expects(static::any())
@@ -76,7 +76,7 @@ class SessionManagerTest extends BaseTestCase
public function testReleaseSessionKey()
{
$clientManager = $this->createMock(JsonRpcClientManager::class);
$clientManager = $this->createMock(JsonRpcClientManager::className);
$clientManager
->expects(static::any())
@@ -84,6 +84,6 @@ class SessionManagerTest extends BaseTestCase
->willReturn([]);
$sessionManager = new SessionManager($clientManager);
static::assertInstanceOf(SessionManager::class, $sessionManager->releaseSessionKey());
static::assertInstanceOf(SessionManager::className, $sessionManager->releaseSessionKey());
}
}

View File

@@ -47,24 +47,24 @@ class ParticipantsTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(Participants::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(Participants::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testAdd()
{
$this->expectException(DisabledMethodException::class);
$this->setExpectedException(DisabledMethodException::className);
(new Participants())->add('');
}
public function testAddMultiple()
{
$this->expectException(DisabledMethodException::class);
$this->setExpectedException(DisabledMethodException::className);
(new Participants())->addMultiple([]);
}
public function testHas()
{
$this->expectException(DisabledMethodException::class);
$this->setExpectedException(DisabledMethodException::className);
(new Participants())->has(new Participant());
}

View File

@@ -37,7 +37,7 @@ class SurveysTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(Surveys::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(Surveys::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testAddWithoutIndex()

View File

@@ -46,7 +46,7 @@ class ParticipantShortTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(ParticipantShort::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(ParticipantShort::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testCreateOfTheParticipant()

View File

@@ -46,7 +46,7 @@ class ParticipantTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(Participant::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(Participant::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testCreateOfTheParticipant()
@@ -54,7 +54,7 @@ class ParticipantTest extends BaseTestCase
$processor = new ResultProcessor();
$processed = $processor->process(MethodType::GET_PARTICIPANT_PROPERTIES, $this->rawData[0]);
static::assertInstanceOf(Participant::class, $processed);
static::assertInstanceOf(Participant::className, $processed);
}
public function testGetId()

View File

@@ -45,7 +45,7 @@ class QuestionShortTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(QuestionShort::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(QuestionShort::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testCreateOfTheQuestionShort()

View File

@@ -45,7 +45,7 @@ class QuestionTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(Question::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(Question::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testCreateOfTheQuestionShort()
@@ -53,7 +53,7 @@ class QuestionTest extends BaseTestCase
$processor = new ResultProcessor();
$processed = $processor->process(MethodType::GET_QUESTION_PROPERTIES, $this->rawData);
static::assertInstanceOf(Question::class, $processed);
static::assertInstanceOf(Question::className, $processed);
}
public function testGetId()

View File

@@ -46,7 +46,7 @@ class SurveyTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(Survey::class, OopVisibilityType::IS_PUBLIC, 1, 0);
static::assertConstructorVisibilityAndArguments(Survey::className, OopVisibilityType::IS_PUBLIC, 1, 0);
}
public function testCreateOfTheSurvey()

View File

@@ -27,7 +27,7 @@ class ResultProcessorTest extends BaseTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertHasNoConstructor(ResultProcessor::class);
static::assertHasNoConstructor(ResultProcessor::className);
}
public function testProcessWithEmptyRawData()
@@ -72,17 +72,17 @@ class ResultProcessorTest extends BaseTestCase
static::assertNotEmpty($processed);
static::assertFalse(is_array($processed));
static::assertInstanceOf(BaseItem::class, $processed);
static::assertInstanceOf(BaseItem::className, $processed);
}
public function testGetItemClassNameVisibilityAndArguments()
{
static::assertMethodVisibilityAndArguments(ResultProcessor::class, 'getItemClassName', OopVisibilityType::IS_PRIVATE, 1, 1);
static::assertMethodVisibilityAndArguments(ResultProcessor::className, 'getItemClassName', OopVisibilityType::IS_PRIVATE, 1, 1);
}
public function testRunWithUnknownResultClass()
{
$this->expectException(UnknownInstanceOfResultItem::class);
$this->setExpectedException(UnknownInstanceOfResultItem::className);
$rawData = [
'lorem' => 'ipsum',

View File

@@ -87,7 +87,7 @@ class ResultTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(Result::class, OopVisibilityType::IS_PUBLIC, 2, 2);
static::assertConstructorVisibilityAndArguments(Result::className, OopVisibilityType::IS_PUBLIC, 2, 2);
}
public function testIsEmpty()
@@ -108,7 +108,7 @@ class ResultTest extends BaseTestCase
static::assertCount(count($this->emptyData), $emptyData);
static::assertCount(count($this->iterableData), $iterableData);
static::assertInstanceOf(BaseItem::class, $notIterableData);
static::assertInstanceOf(BaseItem::className, $notIterableData);
}
public function testGetDataUsingRawData()
@@ -128,18 +128,18 @@ class ResultTest extends BaseTestCase
public function testGetDataUsingProcessedDataWhoCannotBeProcessed()
{
$this->expectException(CannotProcessDataException::class);
$this->setExpectedException(CannotProcessDataException::className);
$this->statusInsteadDataResult->getData();
}
public function testGetProcessedDataVisibilityAndArguments()
{
static::assertMethodVisibilityAndArguments(Result::class, 'getProcessedData', OopVisibilityType::IS_PRIVATE, 1, 1);
static::assertMethodVisibilityAndArguments(Result::className, 'getProcessedData', OopVisibilityType::IS_PRIVATE, 1, 1);
}
public function testGetResultProcessorVisibilityAndArguments()
{
static::assertMethodVisibilityAndArguments(Result::class, 'getResultProcessor', OopVisibilityType::IS_PRIVATE);
static::assertMethodVisibilityAndArguments(Result::className, 'getResultProcessor', OopVisibilityType::IS_PRIVATE);
}
public function testGetStatusWhenIsNotProvided()
@@ -218,6 +218,6 @@ class ResultTest extends BaseTestCase
*/
private function getResultMock($constructorArguments)
{
return $this->getMockForAbstractClass(Result::class, $constructorArguments);
return $this->getMockForAbstractClass(Result::className, $constructorArguments);
}
}

View File

@@ -51,7 +51,7 @@ class ParticipantServiceTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(ParticipantService::class, OopVisibilityType::IS_PUBLIC, 2, 1);
static::assertConstructorVisibilityAndArguments(ParticipantService::className, OopVisibilityType::IS_PUBLIC, 2, 1);
}
public function testGetClient()
@@ -62,8 +62,8 @@ class ParticipantServiceTest extends BaseTestCase
$this->createServiceWithoutParticipants($rpcClientManager, $sessionManager);
$this->createServiceWithParticipants($rpcClientManager, $sessionManager);
static::assertInstanceOf(Client::class, $this->serviceWithoutParticipants->getClient());
static::assertInstanceOf(Client::class, $this->serviceWithParticipants->getClient());
static::assertInstanceOf(Client::className, $this->serviceWithoutParticipants->getClient());
static::assertInstanceOf(Client::className, $this->serviceWithParticipants->getClient());
$connectionConfiguration = $this->getConnectionConfiguration();
$client = new Client($connectionConfiguration);
@@ -90,7 +90,7 @@ class ParticipantServiceTest extends BaseTestCase
public function testGetSurveyParticipantsWithImportantException()
{
$this->expectException(CannotProcessDataException::class);
$this->setExpectedException(CannotProcessDataException::className);
$exception = new CannotProcessDataException(ReasonType::NO_TOKEN_TABLE);
$rpcClientManager = $this->getJsonRpcClientManagerWithException(1, $exception);
@@ -129,7 +129,7 @@ class ParticipantServiceTest extends BaseTestCase
public function testAddParticipantForNotExistingSurvey()
{
$this->expectException(CannotProcessDataException::class);
$this->setExpectedException(CannotProcessDataException::className);
$exception = new CannotProcessDataException(ReasonType::NOT_EXISTING_SURVEY_ID);
$rpcClientManager = $this->getJsonRpcClientManagerWithException(1, $exception);
@@ -169,7 +169,7 @@ class ParticipantServiceTest extends BaseTestCase
$this->createServiceWithoutParticipants($rpcClientManager, $sessionManager);
$result = $this->serviceWithoutParticipants->addParticipant($surveyId, $firstName, $lastName, $email);
static::assertInstanceOf(Participant::class, $result);
static::assertInstanceOf(Participant::className, $result);
static::assertEquals($firstName, $result->getFirstName());
static::assertEquals($lastName, $result->getLastName());
static::assertEquals($email, $result->getEmail());
@@ -186,7 +186,7 @@ class ParticipantServiceTest extends BaseTestCase
static::assertNull($this->serviceWithoutParticipants->getParticipant(1, 'john@scott.com'));
$participant = $this->serviceWithParticipants->getParticipant(1, 'john@scott.com');
static::assertInstanceOf(ParticipantShort::class, $participant);
static::assertInstanceOf(ParticipantShort::className, $participant);
static::assertEquals('John', $participant->getFirstName());
static::assertEquals('Scott', $participant->getLastName());
static::assertEquals('john@scott.com', $participant->getEmail());
@@ -215,7 +215,7 @@ class ParticipantServiceTest extends BaseTestCase
static::assertNull($this->serviceWithoutParticipants->getParticipantDetails(1, 'john@scott.com'));
$participant = $this->serviceWithParticipants->getParticipantDetails(1, 'john@scott.com');
static::assertInstanceOf(Participant::class, $participant);
static::assertInstanceOf(Participant::className, $participant);
static::assertEquals($runMethodCallResults['tid'], $participant->getId());
static::assertEquals($runMethodCallResults['firstname'], $participant->getFirstName());
static::assertEquals($runMethodCallResults['lastname'], $participant->getLastName());
@@ -229,7 +229,7 @@ class ParticipantServiceTest extends BaseTestCase
public function testHasParticipantFilledSurveyWithException()
{
$this->expectException(MissingParticipantOfSurveyException::class);
$this->setExpectedException(MissingParticipantOfSurveyException::className);
$rpcClientManager = $this->getJsonRpcClientManager(1);
$sessionManager = $this->getSessionManager();
@@ -256,7 +256,7 @@ class ParticipantServiceTest extends BaseTestCase
public function testHasParticipantFilledSurveyUsingNotExistingParticipant()
{
$this->expectException(MissingParticipantOfSurveyException::class);
$this->setExpectedException(MissingParticipantOfSurveyException::className);
$rpcClientManager = $this->getJsonRpcClientManager(1);
$sessionManager = $this->getSessionManager();
@@ -282,7 +282,7 @@ class ParticipantServiceTest extends BaseTestCase
*/
private function getSessionManager()
{
return $this->createMock(SessionManager::class);
return $this->createMock(SessionManager::className);
}
/**
@@ -294,7 +294,7 @@ class ParticipantServiceTest extends BaseTestCase
*/
private function getJsonRpcClientManager($runMethodCallCount, array $runMethodCallResults = [])
{
$rpcClientManager = $this->createMock(JsonRpcClientManager::class);
$rpcClientManager = $this->createMock(JsonRpcClientManager::className);
$rpcClientManager
->expects(static::exactly($runMethodCallCount))
@@ -314,7 +314,7 @@ class ParticipantServiceTest extends BaseTestCase
*/
private function getJsonRpcClientManagerWithException($runMethodCallCount, Exception $exception)
{
$rpcClientManager = $this->createMock(JsonRpcClientManager::class);
$rpcClientManager = $this->createMock(JsonRpcClientManager::className);
$rpcClientManager
->expects(static::exactly($runMethodCallCount))

View File

@@ -57,7 +57,7 @@ class SurveyServiceTest extends BaseTestCase
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(SurveyService::class, OopVisibilityType::IS_PUBLIC, 2, 1);
static::assertConstructorVisibilityAndArguments(SurveyService::className, OopVisibilityType::IS_PUBLIC, 2, 1);
}
public function testGetClient()
@@ -68,8 +68,8 @@ class SurveyServiceTest extends BaseTestCase
$this->createServiceWithoutSurveys($rpcClientManager, $sessionManager);
$this->createServiceWithSurveys($rpcClientManager, $sessionManager);
static::assertInstanceOf(Client::class, $this->serviceWithoutSurveys->getClient());
static::assertInstanceOf(Client::class, $this->serviceWithSurveys->getClient());
static::assertInstanceOf(Client::className, $this->serviceWithoutSurveys->getClient());
static::assertInstanceOf(Client::className, $this->serviceWithSurveys->getClient());
$connectionConfiguration = $this->getConnectionConfiguration();
$client = new Client($connectionConfiguration);
@@ -80,7 +80,7 @@ class SurveyServiceTest extends BaseTestCase
public function testGetAllSurveysWithImportantException()
{
$this->expectException(CannotProcessDataException::class);
$this->setExpectedException(CannotProcessDataException::className);
$exception = new CannotProcessDataException(ReasonType::NO_TOKEN_TABLE);
$rpcClientManager = $this->getJsonRpcClientManagerWithException(1, $exception);
@@ -202,7 +202,7 @@ class SurveyServiceTest extends BaseTestCase
*/
private function getSessionManager()
{
return $this->createMock(SessionManager::class);
return $this->createMock(SessionManager::className);
}
/**
@@ -214,7 +214,7 @@ class SurveyServiceTest extends BaseTestCase
*/
private function getJsonRpcClientManager($runMethodCallCount, array $runMethodCallResults = [])
{
$rpcClientManager = $this->createMock(JsonRpcClientManager::class);
$rpcClientManager = $this->createMock(JsonRpcClientManager::className);
$rpcClientManager
->expects(static::exactly($runMethodCallCount))
@@ -234,7 +234,7 @@ class SurveyServiceTest extends BaseTestCase
*/
private function getJsonRpcClientManagerWithException($runMethodCallCount, Exception $exception)
{
$rpcClientManager = $this->createMock(JsonRpcClientManager::class);
$rpcClientManager = $this->createMock(JsonRpcClientManager::className);
$rpcClientManager
->expects(static::exactly($runMethodCallCount))

View File

@@ -8,7 +8,6 @@
namespace Meritoo\LimeSurvey\Test\ApiClient\Type;
use Generator;
use Meritoo\Common\Test\Base\BaseTypeTestCase;
use Meritoo\LimeSurvey\ApiClient\Exception\UnknownMethodException;
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
@@ -24,7 +23,7 @@ class MethodTypeTest extends BaseTypeTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertHasNoConstructor(MethodType::class);
static::assertHasNoConstructor(MethodType::className);
}
/**
@@ -33,7 +32,7 @@ class MethodTypeTest extends BaseTypeTestCase
*/
public function testGetValidatedMethodWithIncorrectMethod($incorrectMethod)
{
$this->expectException(UnknownMethodException::class);
$this->setExpectedException(UnknownMethodException::className);
MethodType::getValidatedMethod($incorrectMethod);
}
@@ -52,7 +51,7 @@ class MethodTypeTest extends BaseTypeTestCase
*/
public function testIsResultIterableWithIncorrectMethod($incorrectMethod)
{
$this->expectException(UnknownMethodException::class);
$this->setExpectedException(UnknownMethodException::className);
MethodType::isResultIterable($incorrectMethod);
}
@@ -70,10 +69,33 @@ class MethodTypeTest extends BaseTypeTestCase
/**
* Provides correct type of method
*
* @return Generator
* @return array
* //return Generator
*/
public function provideMethod()
{
return [
[
MethodType::ADD_RESPONSE,
],
[
MethodType::EXPORT_STATISTICS,
],
[
MethodType::GET_PARTICIPANT_PROPERTIES,
],
[
MethodType::LIST_SURVEYS,
],
[
SystemMethodType::GET_SESSION_KEY,
],
[
SystemMethodType::RELEASE_SESSION_KEY,
],
];
/*
yield[
MethodType::ADD_RESPONSE,
];
@@ -97,15 +119,36 @@ class MethodTypeTest extends BaseTypeTestCase
yield[
SystemMethodType::RELEASE_SESSION_KEY,
];
*/
}
/**
* Provides incorrect type of method
*
* @return Generator
* @return array
* //return Generator
*/
public function provideIncorrectMethod()
{
return [
[
'',
],
[
null,
],
[
true,
],
[
false,
],
[
'lorem',
],
];
/*
yield[
'',
];
@@ -125,15 +168,45 @@ class MethodTypeTest extends BaseTypeTestCase
yield[
'lorem',
];
*/
}
/**
* Provides type of method who result provided by the API is iterable and information if it's iterable
*
* @return Generator
* @return array
* //return Generator
*/
public function provideIterableType()
{
return [
[
MethodType::ADD_RESPONSE,
false,
],
[
MethodType::GET_PARTICIPANT_PROPERTIES,
false,
],
[
MethodType::LIST_PARTICIPANTS,
true,
],
[
MethodType::LIST_QUESTIONS,
true,
],
[
MethodType::LIST_SURVEYS,
true,
],
[
MethodType::LIST_USERS,
true,
],
];
/*
yield[
MethodType::ADD_RESPONSE,
false,
@@ -163,6 +236,7 @@ class MethodTypeTest extends BaseTypeTestCase
MethodType::LIST_USERS,
true,
];
*/
}
/**
@@ -196,6 +270,26 @@ class MethodTypeTest extends BaseTypeTestCase
*/
public function provideTypeToVerify()
{
return [
[
'',
false,
],
[
'lorem',
false,
],
[
MethodType::ADD_RESPONSE,
true,
],
[
MethodType::GET_PARTICIPANT_PROPERTIES,
true,
],
];
/*
yield[
'',
false,
@@ -215,5 +309,6 @@ class MethodTypeTest extends BaseTypeTestCase
MethodType::GET_PARTICIPANT_PROPERTIES,
true,
];
*/
}
}

View File

@@ -21,7 +21,7 @@ class ReasonTypeTest extends BaseTypeTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertHasNoConstructor(ReasonType::class);
static::assertHasNoConstructor(ReasonType::className);
}
/**
@@ -50,6 +50,34 @@ class ReasonTypeTest extends BaseTypeTestCase
*/
public function provideTypeToVerify()
{
return [
[
'',
false,
],
[
'lorem',
false,
],
[
ReasonType::NOT_EXISTING_SURVEY_ID,
true,
],
[
ReasonType::NO_PARTICIPANTS_FOUND,
true,
],
[
ReasonType::NO_SURVEYS_FOUND,
true,
],
[
ReasonType::NO_TOKEN_TABLE,
true,
],
];
/*
yield[
'',
false,
@@ -79,5 +107,6 @@ class ReasonTypeTest extends BaseTypeTestCase
ReasonType::NO_TOKEN_TABLE,
true,
];
*/
}
}

View File

@@ -21,7 +21,7 @@ class SystemMethodTypeTest extends BaseTypeTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertHasNoConstructor(SystemMethodType::class);
static::assertHasNoConstructor(SystemMethodType::className);
}
/**
@@ -48,6 +48,26 @@ class SystemMethodTypeTest extends BaseTypeTestCase
*/
public function provideTypeToVerify()
{
return [
[
'',
false,
],
[
'lorem',
false,
],
[
SystemMethodType::GET_SESSION_KEY,
true,
],
[
SystemMethodType::RELEASE_SESSION_KEY,
true,
],
];
/*
yield[
'',
false,
@@ -67,5 +87,6 @@ class SystemMethodTypeTest extends BaseTypeTestCase
SystemMethodType::RELEASE_SESSION_KEY,
true,
];
*/
}
}