mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 02:11:45 +01:00
First, initial commit
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
<?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\Manager;
|
||||
|
||||
use JsonRPC\Client as RpcClient;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
use Meritoo\LimeSurvey\ApiClient\Configuration\ConnectionConfiguration;
|
||||
use Meritoo\LimeSurvey\ApiClient\Manager\JsonRpcClientManager;
|
||||
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
|
||||
use Meritoo\LimeSurvey\Test\ApiClient\Result\Item\SurveyTest;
|
||||
|
||||
/**
|
||||
* Test case of the manager of the JsonRPC client used while connecting to LimeSurvey's API
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class JsonRpcClientManagerTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Configuration used while connecting to LimeSurvey's API
|
||||
*
|
||||
* @var ConnectionConfiguration
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
$this->verifyConstructorVisibilityAndArguments(JsonRpcClientManager::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
}
|
||||
|
||||
public function testRunMethod()
|
||||
{
|
||||
$rpcClient = $this->createMock(RpcClient::class);
|
||||
|
||||
$manager = $this
|
||||
->getMockBuilder(JsonRpcClientManager::class)
|
||||
->setConstructorArgs([
|
||||
$this->configuration,
|
||||
])
|
||||
->setMethods([
|
||||
'getRpcClient',
|
||||
])
|
||||
->getMock();
|
||||
|
||||
$rpcClient
|
||||
->expects(static::any())
|
||||
->method('execute')
|
||||
->willReturn([]);
|
||||
|
||||
$manager
|
||||
->expects(static::any())
|
||||
->method('getRpcClient')
|
||||
->willReturn($rpcClient);
|
||||
|
||||
/* @var JsonRpcClientManager $manager */
|
||||
static::assertEquals([], $manager->runMethod(MethodType::LIST_SURVEYS));
|
||||
}
|
||||
|
||||
public function testRunMethodWithMockedRpcClient()
|
||||
{
|
||||
$rpcClient = $this->createMock(RpcClient::class);
|
||||
$manager = $this->createPartialMock(JsonRpcClientManager::class, ['getRpcClient']);
|
||||
|
||||
$rpcClient
|
||||
->expects(static::any())
|
||||
->method('execute')
|
||||
->willReturn(SurveyTest::getSurveysRawData());
|
||||
|
||||
$manager
|
||||
->expects(static::any())
|
||||
->method('getRpcClient')
|
||||
->willReturn($rpcClient);
|
||||
|
||||
/* @var JsonRpcClientManager $manager */
|
||||
static::assertEquals(SurveyTest::getSurveysRawData(), $manager->runMethod(MethodType::LIST_SURVEYS));
|
||||
}
|
||||
|
||||
public function testGetRpcClientVisibilityAndArguments()
|
||||
{
|
||||
$this->verifyMethodVisibilityAndArguments(JsonRpcClientManager::class, 'getRpcClient', OopVisibilityType::IS_PROTECTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->configuration = new ConnectionConfiguration('http://test.com', 'test', 'test');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user