Files
pcm-icon-bundle/tests/Config/ConfigurationTest.php
2023-05-30 17:05:31 +01:00

65 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace Pcm\IconBundle\Tests\Config;
use Pcm\IconBundle\DependencyInjection\Configuration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
class ConfigurationTest extends TestCase
{
private Configuration $configuration;
private Processor $processor;
protected function setUp(): void
{
$this->configuration = new Configuration();
$this->processor = new Processor();
}
public function testThrowsIfDirectoriesIsEmpty()
{
$config = $this->getValidConfig();
$config['directories'] = [];
$this->expectExceptionMessage("Directories cannot be empty!");
$this->validateConfig($config);
}
public function testThrowsIfDirectoryIsNotFound(): void
{
$config = $this->getValidConfig();
$fakeDir = "abc/def/ghi";
$config['directories'] = [$fakeDir];
$this->expectExceptionMessage("\"abc\/def\/ghi\" is not a directory!");
$this->validateConfig($config);
}
private function validateConfig(array $config): void
{
$this->processor->processConfiguration($this->configuration, [$config]);
}
private function getValidConfig(): array
{
return [
'directories' => [
'./',
],
'palletes' => [
'primary' => [
'fill' => 'fill-primary',
'stroke' => 'stroke-primary',
'fill-hover' => 'hover:fill-primary',
'stroke-hover' => 'hover:stroke-primary',
'fill-group-hover' => 'group-hover:fill-primary',
'stroke-group-hover' => 'group-hover:stroke-primary',
],
],
];
}
}