Test directory validation
This commit is contained in:
67
tests/Config/ConfigurationTest.php
Normal file
67
tests/Config/ConfigurationTest.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use function Symfony\Component\VarDumper\Dumper\esc;
|
||||||
|
|
||||||
|
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' => [
|
||||||
|
'prmary' => [
|
||||||
|
'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',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user