Skip to content

Commit

Permalink
Test(web-twig): Upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janicekt authored and literat committed Jul 30, 2022
1 parent 5cbe22e commit eceb775
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Lmc\SpiritWebTwigBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class SpiritWebTwigExtension extends Extension
{
public const PARAMETER_PATH = 'spirit_web_twig.path';

public const PARAMETER_PATH_ALIAS = 'spirit_web_twig.path_alias';

public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');

$container->setParameter(self::PARAMETER_PATH, $config['path']);
$container->setParameter(self::PARAMETER_PATH_ALIAS, $config['path_alias']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class TwigComponentsExtension extends Extension
class SpiritWebTwigExtension extends Extension
{
public const PARAMETER_PATH = 'spirit_web_twig.path';

Expand Down
2 changes: 0 additions & 2 deletions packages/web-twig/tests/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace Lmc\SpiritWebTwigBundle;

use Lmc\SpiritWebTwigBundle\Compiler\ComponentLexer;
use Lmc\SpiritWebTwigBundle\Factory\TwigFactory;
use Mockery;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Lmc\SpiritWebTwigBundle\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class SpiritWebTwigExtensionTest extends TestCase
{
private ContainerBuilder $containerBuilder;

protected function setUp(): void
{
$config = [
'path' => 'templates/',
'path_alias' => 'ui-components',
];

$this->loadExtension([$config]);
}

private function loadExtension(array $configs): void
{
$extension = new SpiritWebTwigExtension();
$this->containerBuilder = new ContainerBuilder();
$this->containerBuilder->registerExtension($extension);

$extension->load($configs, $this->containerBuilder);
}

public function testShouldRegisterParameters(): void
{
$this->assertTrue($this->containerBuilder->hasParameter('spirit_web_twig.path'));
$this->assertTrue($this->containerBuilder->hasParameter('spirit_web_twig.path_alias'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class TwigComponentsExtensionTest extends TestCase
class SpiritWebTwigExtensionTest extends TestCase
{
private ContainerBuilder $containerBuilder;

Expand All @@ -23,7 +23,7 @@ protected function setUp(): void

private function loadExtension(array $configs): void
{
$extension = new TwigComponentsExtension();
$extension = new SpiritWebTwigExtension();
$this->containerBuilder = new ContainerBuilder();
$this->containerBuilder->registerExtension($extension);

Expand Down

0 comments on commit eceb775

Please sign in to comment.