46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pcm\MetadataBundle\Tests\Config;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
|
|
use Symfony\Component\Config\Definition\Processor;
|
|
|
|
/**
|
|
* This file tests the config to ensure that the config validation is working as expected.
|
|
*/
|
|
class ConfigurationTest extends TestCase
|
|
{
|
|
private Configuration $configuration;
|
|
private Processor $processor;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->configuration = new Configuration(true);
|
|
$this->processor = new Processor();
|
|
}
|
|
|
|
public function testThrowsIfNameIsEmpty()
|
|
{
|
|
$config = $this->getValidConfig();
|
|
$config['name'] = '';
|
|
$this->expectException(\Exception::class);
|
|
$this->validateConfig($config);
|
|
}
|
|
|
|
private function validateConfig(array $config): array
|
|
{
|
|
return $this->processor->processConfiguration($this->configuration, [$config]);
|
|
}
|
|
|
|
private function getValidConfig(): array
|
|
{
|
|
return [
|
|
'name' => 'Boris',
|
|
];
|
|
}
|
|
}
|
|
|