mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 18:11:50 +01:00
74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Meritoo\LimeSurvey\Test\ApiClient\Exception;
|
|
|
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
|
use Meritoo\Common\Type\OopVisibilityType;
|
|
use Meritoo\LimeSurvey\ApiClient\Exception\CannotProcessDataException;
|
|
|
|
/**
|
|
* Test case of an exception used while raw data returned by the LimeSurvey's API cannot be processed
|
|
*
|
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
|
* @copyright Meritoo.pl
|
|
*/
|
|
class CannotProcessDataExceptionTest extends BaseTestCase
|
|
{
|
|
public function testConstructorVisibilityAndArguments()
|
|
{
|
|
static::assertConstructorVisibilityAndArguments(CannotProcessDataException::className, OopVisibilityType::IS_PUBLIC, 1, 1);
|
|
}
|
|
|
|
/**
|
|
* @param string $reason Reason why data cannot be processed, e.g. "Invalid user name or password"
|
|
* @param string $expectedMessage Expected exception's message
|
|
*
|
|
* @dataProvider provideReason
|
|
*/
|
|
public function testConstructorMessage($reason, $expectedMessage)
|
|
{
|
|
$exception = new CannotProcessDataException($reason);
|
|
static::assertEquals($expectedMessage, $exception->getMessage());
|
|
}
|
|
|
|
/**
|
|
* Provides reason why data cannot be processed
|
|
*
|
|
* @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'),
|
|
];
|
|
|
|
yield[
|
|
'Invalid user name or password',
|
|
sprintf($template, 'Invalid user name or password'),
|
|
];
|
|
*/
|
|
}
|
|
}
|