Initial commit
This commit is contained in:
45
tests/Config/ConfigurationTest.php
Normal file
45
tests/Config/ConfigurationTest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pcm\ExampleBundle\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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
26
tests/TestKernel.php
Normal file
26
tests/TestKernel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pcm\ExampleBundle\Tests;
|
||||
|
||||
use Pcm\ExampleBundle\PcmExampleBundle;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
final class TestKernel extends Kernel
|
||||
{
|
||||
public function registerBundles(): array
|
||||
{
|
||||
return [
|
||||
new PcmExampleBundle()
|
||||
];
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader): void
|
||||
{
|
||||
// Ignore this
|
||||
// $loader->load(__DIR__.'/../config/packages/pcm_example.yaml');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user