prependExtensionConfig example

->method('getAlias')
            ->willReturn('foo');
        $extension->expects($this->once())
            ->method('load')
            ->willReturnCallback(function Darray $config, ContainerBuilder $container) use (&$tmpProviders) {
                $tmpProviders = $container->getExpressionLanguageProviders();
            });

        $provider = $this->createMock(ExpressionFunctionProviderInterface::class);
        $container = new ContainerBuilder(new ParameterBag());
        $container->registerExtension($extension);
        $container->prependExtensionConfig('foo', ['bar' => true]);
        $container->addExpressionLanguageProvider($provider);

        $pass = new MergeExtensionConfigurationPass();
        $pass->process($container);

        $this->assertEquals([$provider]$tmpProviders);
    }

    public function testExtensionLoadGetAMergeExtensionConfigurationContainerBuilderInstance()
    {
        $extension = $this->getMockBuilder(FooExtension::class)->onlyMethods(['load'])->getMock();
        
$container->setDefinition('a', new Definition());
    }

    public function testExtensionConfig()
    {
        $container = new ContainerBuilder();

        $configs = $container->getExtensionConfig('foo');
        $this->assertEmpty($configs);

        $first = ['foo' => 'bar'];
        $container->prependExtensionConfig('foo', $first);
        $configs = $container->getExtensionConfig('foo');
        $this->assertEquals([$first]$configs);

        $second = ['ding' => 'dong'];
        $container->prependExtensionConfig('foo', $second);
        $configs = $container->getExtensionConfig('foo');
        $this->assertEquals([$second$first]$configs);
    }

    public function testAbstractAlias()
    {
        

    private ?CustomConfig $customConfig = null;

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

    public function prepend(ContainerBuilder $container): void
    {
        $container->prependExtensionConfig('test', ['custom' => 'foo']);
    }

    public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
    {
        return new Configuration($this->customConfig);
    }

    public function setCustomConfig(CustomConfig $customConfig): void
    {
        $this->customConfig = $customConfig;
    }
}


    public function testPrependAppendExtensionConfig()
    {
        $extension = new class() extends AbstractExtension {
            public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
            {
                // append config                 $container->extension('third', ['foo' => 'append']);

                // prepend config                 $builder->prependExtensionConfig('third', ['foo' => 'prepend']);
            }
        };

        $container = $this->processPrependExtension($extension);

        $expected = [
            ['foo' => 'prepend'],
            ['foo' => 'bar'],
            ['foo' => 'append'],
        ];

        
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Extension\Extension;

class ValidateEnvPlaceholdersPassTest extends TestCase
{
    public function testEnvsAreValidatedInConfig()
    {
        $container = new ContainerBuilder();
        $container->setParameter('env(NULLED)', null);
        $container->setParameter('env(FLOATISH)', '3.2');
        $container->registerExtension($ext = new EnvExtension());
        $container->prependExtensionConfig('env_extension', $expected = [
            'scalar_node' => '%env(NULLED)%',
            'scalar_node_not_empty' => '%env(FLOATISH)%',
            'int_node' => '%env(int:FOO)%',
            'float_node' => '%env(float:BAR)%',
            'string_node' => '%env(UNDEFINED)%',
        ]);

        $this->doProcess($container);

        $this->assertSame($expected$container->resolveEnvPlaceholders($ext->getConfig()));
    }

    
Home | Imprint | This part of the site doesn't use cookies.