2021-02-05 14:47:54 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace RetailCrm\ServiceBundle\Tests\DependencyInjection;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use RetailCrm\ServiceBundle\DependencyInjection\Configuration;
|
|
|
|
use Symfony\Component\Config\Definition\Processor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ConfigurationTest
|
|
|
|
*
|
|
|
|
* @package RetailCrm\ServiceBundle\Tests\DependencyInjection
|
|
|
|
*/
|
|
|
|
class ConfigurationTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testConfig(): void
|
|
|
|
{
|
|
|
|
$processor = new Processor();
|
|
|
|
|
|
|
|
$configs = [
|
|
|
|
[
|
|
|
|
'request_schema' => [
|
|
|
|
'callback' => [
|
2021-02-17 09:31:36 +03:00
|
|
|
'supports' => [
|
|
|
|
[
|
|
|
|
'type' => 'type',
|
|
|
|
'params' => ['param']
|
|
|
|
]
|
2021-02-05 14:47:54 +03:00
|
|
|
]
|
|
|
|
],
|
|
|
|
'client' => [
|
2021-02-17 09:31:36 +03:00
|
|
|
'supports' => [
|
|
|
|
'type1',
|
|
|
|
'type2'
|
|
|
|
]
|
2021-02-05 14:47:54 +03:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
$config = $processor->processConfiguration(new Configuration(), $configs);
|
|
|
|
|
|
|
|
static::assertArrayHasKey('request_schema', $config);
|
|
|
|
static::assertArrayHasKey('callback', $config['request_schema']);
|
|
|
|
static::assertArrayHasKey('client', $config['request_schema']);
|
|
|
|
static::assertEquals(
|
|
|
|
[
|
|
|
|
'type' => 'type',
|
|
|
|
'params' => ['param']
|
|
|
|
],
|
2021-02-17 09:31:36 +03:00
|
|
|
$config['request_schema']['callback']['supports'][0]
|
2021-02-05 14:47:54 +03:00
|
|
|
);
|
|
|
|
static::assertEquals(
|
|
|
|
[
|
|
|
|
'type1',
|
|
|
|
'type2'
|
|
|
|
],
|
2021-02-17 09:31:36 +03:00
|
|
|
$config['request_schema']['client']['supports']
|
2021-02-05 14:47:54 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPartConfig(): void
|
|
|
|
{
|
|
|
|
$processor = new Processor();
|
|
|
|
|
|
|
|
$configs = [
|
|
|
|
[
|
|
|
|
'request_schema' => [
|
|
|
|
'client' => [
|
2021-02-17 09:31:36 +03:00
|
|
|
'supports' => [
|
|
|
|
'type',
|
|
|
|
]
|
2021-02-05 14:47:54 +03:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
$config = $processor->processConfiguration(new Configuration(), $configs);
|
|
|
|
|
|
|
|
static::assertArrayHasKey('client', $config['request_schema']);
|
2021-02-17 09:31:36 +03:00
|
|
|
static::assertEquals(['type'], $config['request_schema']['client']['supports']);
|
2021-02-05 14:47:54 +03:00
|
|
|
}
|
|
|
|
}
|