mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°2651 rollback gitignore for lib tests dirs
Too dangerous ! We'll work properly on this but for 2.8
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class AddCacheWarmerPassTest extends TestCase
|
||||
{
|
||||
public function testThatCacheWarmersAreProcessedInPriorityOrder()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$cacheWarmerDefinition = $container->register('cache_warmer')->addArgument([]);
|
||||
$container->register('my_cache_warmer_service1')->addTag('kernel.cache_warmer', ['priority' => 100]);
|
||||
$container->register('my_cache_warmer_service2')->addTag('kernel.cache_warmer', ['priority' => 200]);
|
||||
$container->register('my_cache_warmer_service3')->addTag('kernel.cache_warmer');
|
||||
|
||||
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||
$addCacheWarmerPass->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
new Reference('my_cache_warmer_service2'),
|
||||
new Reference('my_cache_warmer_service1'),
|
||||
new Reference('my_cache_warmer_service3'),
|
||||
],
|
||||
$cacheWarmerDefinition->getArgument(0)
|
||||
);
|
||||
}
|
||||
|
||||
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||
$addCacheWarmerPass->process($container);
|
||||
|
||||
// we just check that the pass does not break if no cache warmer is registered
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testThatCacheWarmersMightBeNotDefined()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$cacheWarmerDefinition = $container->register('cache_warmer')->addArgument([]);
|
||||
|
||||
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||
$addCacheWarmerPass->process($container);
|
||||
|
||||
$this->assertSame([], $cacheWarmerDefinition->getArgument(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class AddConsoleCommandPassTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider visibilityProvider
|
||||
*/
|
||||
public function testProcess($public)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddConsoleCommandPass());
|
||||
$container->setParameter('my-command.class', 'Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand');
|
||||
|
||||
$definition = new Definition('%my-command.class%');
|
||||
$definition->setPublic($public);
|
||||
$definition->addTag('console.command');
|
||||
$container->setDefinition('my-command', $definition);
|
||||
|
||||
$container->compile();
|
||||
|
||||
$alias = 'console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand';
|
||||
|
||||
if ($public) {
|
||||
$this->assertFalse($container->hasAlias($alias));
|
||||
$id = 'my-command';
|
||||
} else {
|
||||
$id = $alias;
|
||||
// The alias is replaced by a Definition by the ReplaceAliasByActualDefinitionPass
|
||||
// in case the original service is private
|
||||
$this->assertFalse($container->hasDefinition('my-command'));
|
||||
$this->assertTrue($container->hasDefinition($alias));
|
||||
}
|
||||
|
||||
$this->assertTrue($container->hasParameter('console.command.ids'));
|
||||
$this->assertSame([$alias => $id], $container->getParameter('console.command.ids'));
|
||||
}
|
||||
|
||||
public function visibilityProvider()
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The service "my-command" tagged "console.command" must not be abstract.');
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddConsoleCommandPass());
|
||||
|
||||
$definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand');
|
||||
$definition->addTag('console.command');
|
||||
$definition->setAbstract(true);
|
||||
$container->setDefinition('my-command', $definition);
|
||||
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The service "my-command" tagged "console.command" must be a subclass of "Symfony\Component\Console\Command\Command".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddConsoleCommandPass());
|
||||
|
||||
$definition = new Definition('SplObjectStorage');
|
||||
$definition->addTag('console.command');
|
||||
$container->setDefinition('my-command', $definition);
|
||||
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
public function testProcessPrivateServicesWithSameCommand()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$className = 'Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand';
|
||||
|
||||
$definition1 = new Definition($className);
|
||||
$definition1->addTag('console.command')->setPublic(false);
|
||||
|
||||
$definition2 = new Definition($className);
|
||||
$definition2->addTag('console.command')->setPublic(false);
|
||||
|
||||
$container->setDefinition('my-command1', $definition1);
|
||||
$container->setDefinition('my-command2', $definition2);
|
||||
|
||||
(new AddConsoleCommandPass())->process($container);
|
||||
|
||||
$alias1 = 'console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand';
|
||||
$alias2 = $alias1.'_my-command2';
|
||||
$this->assertTrue($container->hasAlias($alias1));
|
||||
$this->assertTrue($container->hasAlias($alias2));
|
||||
}
|
||||
}
|
||||
|
||||
class MyCommand extends Command
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ServiceLocator;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class AddConstraintValidatorsPassTest extends TestCase
|
||||
{
|
||||
public function testThatConstraintValidatorServicesAreProcessed()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$validatorFactory = $container->register('validator.validator_factory')
|
||||
->addArgument([]);
|
||||
|
||||
$container->register('my_constraint_validator_service1', Validator1::class)
|
||||
->addTag('validator.constraint_validator', ['alias' => 'my_constraint_validator_alias1']);
|
||||
$container->register('my_constraint_validator_service2', Validator2::class)
|
||||
->addTag('validator.constraint_validator');
|
||||
|
||||
$addConstraintValidatorsPass = new AddConstraintValidatorsPass();
|
||||
$addConstraintValidatorsPass->process($container);
|
||||
|
||||
$expected = (new Definition(ServiceLocator::class, [[
|
||||
Validator1::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')),
|
||||
'my_constraint_validator_alias1' => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')),
|
||||
Validator2::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service2')),
|
||||
]]))->addTag('container.service_locator')->setPublic(false);
|
||||
$this->assertEquals($expected, $container->getDefinition((string) $validatorFactory->getArgument(0)));
|
||||
}
|
||||
|
||||
public function testAbstractConstraintValidator()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract.');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('validator.validator_factory')
|
||||
->addArgument([]);
|
||||
|
||||
$container->register('my_abstract_constraint_validator')
|
||||
->setAbstract(true)
|
||||
->addTag('validator.constraint_validator');
|
||||
|
||||
$addConstraintValidatorsPass = new AddConstraintValidatorsPass();
|
||||
$addConstraintValidatorsPass->process($container);
|
||||
}
|
||||
|
||||
public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition()
|
||||
{
|
||||
$addConstraintValidatorsPass = new AddConstraintValidatorsPass();
|
||||
$addConstraintValidatorsPass->process(new ContainerBuilder());
|
||||
|
||||
// we just check that the pass does not fail if no constraint validator factory is registered
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class AddExpressionLanguageProvidersPassTest extends TestCase
|
||||
{
|
||||
public function testProcessForRouter()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
|
||||
|
||||
$definition = new Definition('\stdClass');
|
||||
$definition->addTag('routing.expression_language_provider');
|
||||
$container->setDefinition('some_routing_provider', $definition->setPublic(true));
|
||||
|
||||
$container->register('router', '\stdClass')->setPublic(true);
|
||||
$container->compile();
|
||||
|
||||
$router = $container->getDefinition('router');
|
||||
$calls = $router->getMethodCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
$this->assertEquals('addExpressionLanguageProvider', $calls[0][0]);
|
||||
$this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]);
|
||||
}
|
||||
|
||||
public function testProcessForRouterAlias()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
|
||||
|
||||
$definition = new Definition('\stdClass');
|
||||
$definition->addTag('routing.expression_language_provider');
|
||||
$container->setDefinition('some_routing_provider', $definition->setPublic(true));
|
||||
|
||||
$container->register('my_router', '\stdClass')->setPublic(true);
|
||||
$container->setAlias('router', 'my_router');
|
||||
$container->compile();
|
||||
|
||||
$router = $container->getDefinition('my_router');
|
||||
$calls = $router->getMethodCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
$this->assertEquals('addExpressionLanguageProvider', $calls[0][0]);
|
||||
$this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]);
|
||||
}
|
||||
|
||||
public function testProcessForSecurity()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
|
||||
|
||||
$definition = new Definition('\stdClass');
|
||||
$definition->addTag('security.expression_language_provider');
|
||||
$container->setDefinition('some_security_provider', $definition->setPublic(true));
|
||||
|
||||
$container->register('security.expression_language', '\stdClass')->setPublic(true);
|
||||
$container->compile();
|
||||
|
||||
$calls = $container->getDefinition('security.expression_language')->getMethodCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
$this->assertEquals('registerProvider', $calls[0][0]);
|
||||
$this->assertEquals(new Reference('some_security_provider'), $calls[0][1][0]);
|
||||
}
|
||||
|
||||
public function testProcessForSecurityAlias()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
|
||||
|
||||
$definition = new Definition('\stdClass');
|
||||
$definition->addTag('security.expression_language_provider');
|
||||
$container->setDefinition('some_security_provider', $definition->setPublic(true));
|
||||
|
||||
$container->register('my_security.expression_language', '\stdClass')->setPublic(true);
|
||||
$container->setAlias('security.expression_language', 'my_security.expression_language');
|
||||
$container->compile();
|
||||
|
||||
$calls = $container->getDefinition('my_security.expression_language')->getMethodCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
$this->assertEquals('registerProvider', $calls[0][0]);
|
||||
$this->assertEquals(new Reference('some_security_provider'), $calls[0][1][0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
|
||||
use Symfony\Component\Cache\Adapter\TraceableAdapter;
|
||||
use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter;
|
||||
use Symfony\Component\Cache\DataCollector\CacheDataCollector;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class CacheCollectorPassTest extends TestCase
|
||||
{
|
||||
public function testProcess()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container
|
||||
->register('fs', FilesystemAdapter::class)
|
||||
->addTag('cache.pool');
|
||||
$container
|
||||
->register('tagged_fs', TagAwareAdapter::class)
|
||||
->addArgument(new Reference('fs'))
|
||||
->addTag('cache.pool');
|
||||
|
||||
$collector = $container->register('data_collector.cache', CacheDataCollector::class);
|
||||
(new CacheCollectorPass())->process($container);
|
||||
|
||||
$this->assertEquals([
|
||||
['addInstance', ['fs', new Reference('fs')]],
|
||||
['addInstance', ['tagged_fs', new Reference('tagged_fs')]],
|
||||
], $collector->getMethodCalls());
|
||||
|
||||
$this->assertSame(TraceableAdapter::class, $container->findDefinition('fs')->getClass());
|
||||
$this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('tagged_fs')->getClass());
|
||||
$this->assertFalse($collector->isPublic(), 'The "data_collector.cache" should be private after processing');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\RemoveUnusedDefinitionsPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\RepeatedPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
||||
|
||||
class CachePoolClearerPassTest extends TestCase
|
||||
{
|
||||
public function testPoolRefsAreWeak()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.debug', false);
|
||||
$container->setParameter('kernel.name', 'app');
|
||||
$container->setParameter('kernel.environment', 'prod');
|
||||
$container->setParameter('kernel.root_dir', 'foo');
|
||||
|
||||
$globalClearer = new Definition(Psr6CacheClearer::class);
|
||||
$container->setDefinition('cache.global_clearer', $globalClearer);
|
||||
|
||||
$publicPool = new Definition();
|
||||
$publicPool->addArgument('namespace');
|
||||
$publicPool->addTag('cache.pool', ['clearer' => 'clearer_alias']);
|
||||
$container->setDefinition('public.pool', $publicPool);
|
||||
|
||||
$privatePool = new Definition();
|
||||
$privatePool->setPublic(false);
|
||||
$privatePool->addArgument('namespace');
|
||||
$privatePool->addTag('cache.pool', ['clearer' => 'clearer_alias']);
|
||||
$container->setDefinition('private.pool', $privatePool);
|
||||
|
||||
$clearer = new Definition();
|
||||
$container->setDefinition('clearer', $clearer);
|
||||
$container->setAlias('clearer_alias', 'clearer');
|
||||
|
||||
$pass = new RemoveUnusedDefinitionsPass();
|
||||
$pass->setRepeatedPass(new RepeatedPass([$pass]));
|
||||
foreach ([new CachePoolPass(), $pass, new CachePoolClearerPass()] as $pass) {
|
||||
$pass->process($container);
|
||||
}
|
||||
|
||||
$this->assertEquals([['public.pool' => new Reference('public.pool')]], $clearer->getArguments());
|
||||
$this->assertEquals([['public.pool' => new Reference('public.pool')]], $globalClearer->getArguments());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class CachePoolPassTest extends TestCase
|
||||
{
|
||||
private $cachePoolPass;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->cachePoolPass = new CachePoolPass();
|
||||
}
|
||||
|
||||
public function testNamespaceArgumentIsReplaced()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.debug', false);
|
||||
$container->setParameter('kernel.name', 'app');
|
||||
$container->setParameter('kernel.environment', 'prod');
|
||||
$container->setParameter('kernel.root_dir', 'foo');
|
||||
$adapter = new Definition();
|
||||
$adapter->setAbstract(true);
|
||||
$adapter->addTag('cache.pool');
|
||||
$container->setDefinition('app.cache_adapter', $adapter);
|
||||
$container->setAlias('app.cache_adapter_alias', 'app.cache_adapter');
|
||||
$cachePool = new ChildDefinition('app.cache_adapter_alias');
|
||||
$cachePool->addArgument(null);
|
||||
$cachePool->addTag('cache.pool');
|
||||
$container->setDefinition('app.cache_pool', $cachePool);
|
||||
|
||||
$this->cachePoolPass->process($container);
|
||||
|
||||
$this->assertSame('D07rhFx97S', $cachePool->getArgument(0));
|
||||
}
|
||||
|
||||
public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.environment', 'prod');
|
||||
$container->setParameter('kernel.name', 'app');
|
||||
$container->setParameter('kernel.root_dir', 'foo');
|
||||
|
||||
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
|
||||
|
||||
$cachePool = new ChildDefinition('cache.adapter.array');
|
||||
$cachePool->addTag('cache.pool');
|
||||
$container->setDefinition('app.cache_pool', $cachePool);
|
||||
|
||||
$this->cachePoolPass->process($container);
|
||||
|
||||
$this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments());
|
||||
}
|
||||
|
||||
public function testArgsAreReplaced()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.debug', false);
|
||||
$container->setParameter('kernel.name', 'app');
|
||||
$container->setParameter('kernel.environment', 'prod');
|
||||
$container->setParameter('cache.prefix.seed', 'foo');
|
||||
$cachePool = new Definition();
|
||||
$cachePool->addTag('cache.pool', [
|
||||
'provider' => 'foobar',
|
||||
'default_lifetime' => 3,
|
||||
]);
|
||||
$cachePool->addArgument(null);
|
||||
$cachePool->addArgument(null);
|
||||
$cachePool->addArgument(null);
|
||||
$container->setDefinition('app.cache_pool', $cachePool);
|
||||
|
||||
$this->cachePoolPass->process($container);
|
||||
|
||||
$this->assertInstanceOf(Reference::class, $cachePool->getArgument(0));
|
||||
$this->assertSame('foobar', (string) $cachePool->getArgument(0));
|
||||
$this->assertSame('itantF+pIq', $cachePool->getArgument(1));
|
||||
$this->assertSame(3, $cachePool->getArgument(2));
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are');
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.debug', false);
|
||||
$container->setParameter('kernel.name', 'app');
|
||||
$container->setParameter('kernel.environment', 'prod');
|
||||
$container->setParameter('kernel.root_dir', 'foo');
|
||||
$adapter = new Definition();
|
||||
$adapter->setAbstract(true);
|
||||
$adapter->addTag('cache.pool');
|
||||
$container->setDefinition('app.cache_adapter', $adapter);
|
||||
$cachePool = new ChildDefinition('app.cache_adapter');
|
||||
$cachePool->addTag('cache.pool', ['foobar' => 123]);
|
||||
$container->setDefinition('app.cache_pool', $cachePool);
|
||||
|
||||
$this->cachePoolPass->process($container);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class CachePoolPrunerPassTest extends TestCase
|
||||
{
|
||||
public function testCompilerPassReplacesCommandArgument()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('console.command.cache_pool_prune')->addArgument([]);
|
||||
$container->register('pool.foo', FilesystemAdapter::class)->addTag('cache.pool');
|
||||
$container->register('pool.bar', PhpFilesAdapter::class)->addTag('cache.pool');
|
||||
|
||||
$pass = new CachePoolPrunerPass();
|
||||
$pass->process($container);
|
||||
|
||||
$expected = [
|
||||
'pool.foo' => new Reference('pool.foo'),
|
||||
'pool.bar' => new Reference('pool.bar'),
|
||||
];
|
||||
$argument = $container->getDefinition('console.command.cache_pool_prune')->getArgument(0);
|
||||
|
||||
$this->assertInstanceOf(IteratorArgument::class, $argument);
|
||||
$this->assertEquals($expected, $argument->getValues());
|
||||
}
|
||||
|
||||
public function testCompilePassIsIgnoredIfCommandDoesNotExist()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$definitionsBefore = \count($container->getDefinitions());
|
||||
$aliasesBefore = \count($container->getAliases());
|
||||
|
||||
$pass = new CachePoolPrunerPass();
|
||||
$pass->process($container);
|
||||
|
||||
// the container is untouched (i.e. no new definitions or aliases)
|
||||
$this->assertCount($definitionsBefore, $container->getDefinitions());
|
||||
$this->assertCount($aliasesBefore, $container->getAliases());
|
||||
}
|
||||
|
||||
public function testCompilerPassThrowsOnInvalidDefinitionClass()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('console.command.cache_pool_prune')->addArgument([]);
|
||||
$container->register('pool.not-found', NotFound::class)->addTag('cache.pool');
|
||||
|
||||
$pass = new CachePoolPrunerPass();
|
||||
$pass->process($container);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ConfigCachePassTest extends TestCase
|
||||
{
|
||||
public function testThatCheckersAreProcessedInPriorityOrder()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$definition = $container->register('config_cache_factory')->addArgument(null);
|
||||
$container->register('checker_2')->addTag('config_cache.resource_checker', ['priority' => 100]);
|
||||
$container->register('checker_1')->addTag('config_cache.resource_checker', ['priority' => 200]);
|
||||
$container->register('checker_3')->addTag('config_cache.resource_checker');
|
||||
|
||||
$pass = new ConfigCachePass();
|
||||
$pass->process($container);
|
||||
|
||||
$expected = new IteratorArgument([
|
||||
new Reference('checker_1'),
|
||||
new Reference('checker_2'),
|
||||
new Reference('checker_3'),
|
||||
]);
|
||||
$this->assertEquals($expected, $definition->getArgument(0));
|
||||
}
|
||||
|
||||
public function testThatCheckersCanBeMissing()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$definitionsBefore = \count($container->getDefinitions());
|
||||
$aliasesBefore = \count($container->getAliases());
|
||||
|
||||
$pass = new ConfigCachePass();
|
||||
$pass->process($container);
|
||||
|
||||
// the container is untouched (i.e. no new definitions or aliases)
|
||||
$this->assertCount($definitionsBefore, $container->getDefinitions());
|
||||
$this->assertCount($aliasesBefore, $container->getAliases());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ControllerArgumentValueResolverPassTest extends TestCase
|
||||
{
|
||||
public function testServicesAreOrderedAccordingToPriority()
|
||||
{
|
||||
$services = [
|
||||
'n3' => [[]],
|
||||
'n1' => [['priority' => 200]],
|
||||
'n2' => [['priority' => 100]],
|
||||
];
|
||||
|
||||
$expected = [
|
||||
new Reference('n1'),
|
||||
new Reference('n2'),
|
||||
new Reference('n3'),
|
||||
];
|
||||
|
||||
$definition = new Definition(ArgumentResolver::class, [null, []]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->setDefinition('argument_resolver', $definition);
|
||||
|
||||
foreach ($services as $id => list($tag)) {
|
||||
$container->register($id)->addTag('controller.argument_value_resolver', $tag);
|
||||
}
|
||||
|
||||
(new ControllerArgumentValueResolverPass())->process($container);
|
||||
$this->assertEquals($expected, $definition->getArgument(1)->getValues());
|
||||
}
|
||||
|
||||
public function testReturningEmptyArrayWhenNoService()
|
||||
{
|
||||
$definition = new Definition(ArgumentResolver::class, [null, []]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->setDefinition('argument_resolver', $definition);
|
||||
|
||||
(new ControllerArgumentValueResolverPass())->process($container);
|
||||
$this->assertEquals([], $definition->getArgument(1)->getValues());
|
||||
}
|
||||
|
||||
public function testNoArgumentResolver()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
(new ControllerArgumentValueResolverPass())->process($container);
|
||||
|
||||
$this->assertFalse($container->hasDefinition('argument_resolver'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class DataCollectorTranslatorPassTest extends TestCase
|
||||
{
|
||||
private $container;
|
||||
private $dataCollectorTranslatorPass;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->container = new ContainerBuilder();
|
||||
$this->dataCollectorTranslatorPass = new DataCollectorTranslatorPass();
|
||||
|
||||
$this->container->setParameter('translator_implementing_bag', 'Symfony\Component\Translation\Translator');
|
||||
$this->container->setParameter('translator_not_implementing_bag', 'Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag');
|
||||
|
||||
$this->container->register('translator.data_collector', 'Symfony\Component\Translation\DataCollectorTranslator')
|
||||
->setPublic(false)
|
||||
->setDecoratedService('translator')
|
||||
->setArguments([new Reference('translator.data_collector.inner')])
|
||||
;
|
||||
|
||||
$this->container->register('data_collector.translation', 'Symfony\Component\Translation\DataCollector\TranslationDataCollector')
|
||||
->setArguments([new Reference('translator.data_collector')])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getImplementingTranslatorBagInterfaceTranslatorClassNames
|
||||
*/
|
||||
public function testProcessKeepsDataCollectorTranslatorIfItImplementsTranslatorBagInterface($class)
|
||||
{
|
||||
$this->container->register('translator', $class);
|
||||
|
||||
$this->dataCollectorTranslatorPass->process($this->container);
|
||||
|
||||
$this->assertTrue($this->container->hasDefinition('translator.data_collector'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getImplementingTranslatorBagInterfaceTranslatorClassNames
|
||||
*/
|
||||
public function testProcessKeepsDataCollectorIfTranslatorImplementsTranslatorBagInterface($class)
|
||||
{
|
||||
$this->container->register('translator', $class);
|
||||
|
||||
$this->dataCollectorTranslatorPass->process($this->container);
|
||||
|
||||
$this->assertTrue($this->container->hasDefinition('data_collector.translation'));
|
||||
}
|
||||
|
||||
public function getImplementingTranslatorBagInterfaceTranslatorClassNames()
|
||||
{
|
||||
return [
|
||||
['Symfony\Component\Translation\Translator'],
|
||||
['%translator_implementing_bag%'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNotImplementingTranslatorBagInterfaceTranslatorClassNames
|
||||
*/
|
||||
public function testProcessRemovesDataCollectorTranslatorIfItDoesNotImplementTranslatorBagInterface($class)
|
||||
{
|
||||
$this->container->register('translator', $class);
|
||||
|
||||
$this->dataCollectorTranslatorPass->process($this->container);
|
||||
|
||||
$this->assertFalse($this->container->hasDefinition('translator.data_collector'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNotImplementingTranslatorBagInterfaceTranslatorClassNames
|
||||
*/
|
||||
public function testProcessRemovesDataCollectorIfTranslatorDoesNotImplementTranslatorBagInterface($class)
|
||||
{
|
||||
$this->container->register('translator', $class);
|
||||
|
||||
$this->dataCollectorTranslatorPass->process($this->container);
|
||||
|
||||
$this->assertFalse($this->container->hasDefinition('data_collector.translation'));
|
||||
}
|
||||
|
||||
public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames()
|
||||
{
|
||||
return [
|
||||
['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'],
|
||||
['%translator_not_implementing_bag%'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class TranslatorWithTranslatorBag implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
}
|
||||
|
||||
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class FormPassTest extends TestCase
|
||||
{
|
||||
public function testDoNothingIfFormExtensionNotLoaded()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new FormPass());
|
||||
|
||||
$container->compile();
|
||||
|
||||
$this->assertFalse($container->hasDefinition('form.extension'));
|
||||
}
|
||||
|
||||
public function testAddTaggedTypes()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new FormPass());
|
||||
|
||||
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||
$extDefinition->setPublic(true);
|
||||
$extDefinition->setArguments([
|
||||
new Reference('service_container'),
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
]);
|
||||
|
||||
$container->setDefinition('form.extension', $extDefinition);
|
||||
$container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type')->setPublic(true);
|
||||
$container->register('my.type2', __CLASS__.'_Type2')->addTag('form.type')->setPublic(true);
|
||||
|
||||
$container->compile();
|
||||
|
||||
$extDefinition = $container->getDefinition('form.extension');
|
||||
|
||||
$this->assertEquals([
|
||||
__CLASS__.'_Type1' => 'my.type1',
|
||||
__CLASS__.'_Type2' => 'my.type2',
|
||||
], $extDefinition->getArgument(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addTaggedTypeExtensionsDataProvider
|
||||
*/
|
||||
public function testAddTaggedTypeExtensions(array $extensions, array $expectedRegisteredExtensions)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new FormPass());
|
||||
|
||||
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', [
|
||||
new Reference('service_container'),
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
]);
|
||||
$extDefinition->setPublic(true);
|
||||
|
||||
$container->setDefinition('form.extension', $extDefinition);
|
||||
|
||||
foreach ($extensions as $serviceId => $tag) {
|
||||
$container->register($serviceId, 'stdClass')->addTag('form.type_extension', $tag);
|
||||
}
|
||||
|
||||
$container->compile();
|
||||
|
||||
$extDefinition = $container->getDefinition('form.extension');
|
||||
$this->assertSame($expectedRegisteredExtensions, $extDefinition->getArgument(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function addTaggedTypeExtensionsDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
[
|
||||
'my.type_extension1' => ['extended_type' => 'type1'],
|
||||
'my.type_extension2' => ['extended_type' => 'type1'],
|
||||
'my.type_extension3' => ['extended_type' => 'type2'],
|
||||
],
|
||||
[
|
||||
'type1' => ['my.type_extension1', 'my.type_extension2'],
|
||||
'type2' => ['my.type_extension3'],
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
'my.type_extension1' => ['extended_type' => 'type1', 'priority' => 1],
|
||||
'my.type_extension2' => ['extended_type' => 'type1', 'priority' => 2],
|
||||
'my.type_extension3' => ['extended_type' => 'type1', 'priority' => -1],
|
||||
'my.type_extension4' => ['extended_type' => 'type2', 'priority' => 2],
|
||||
'my.type_extension5' => ['extended_type' => 'type2', 'priority' => 1],
|
||||
'my.type_extension6' => ['extended_type' => 'type2', 'priority' => 1],
|
||||
],
|
||||
[
|
||||
'type1' => ['my.type_extension2', 'my.type_extension1', 'my.type_extension3'],
|
||||
'type2' => ['my.type_extension4', 'my.type_extension5', 'my.type_extension6'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttribute()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('extended-type attribute, none was configured for the "my.type_extension" service');
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new FormPass());
|
||||
|
||||
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', [
|
||||
new Reference('service_container'),
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
]);
|
||||
$extDefinition->setPublic(true);
|
||||
|
||||
$container->setDefinition('form.extension', $extDefinition);
|
||||
$container->register('my.type_extension', 'stdClass')
|
||||
->addTag('form.type_extension');
|
||||
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
public function testAddTaggedGuessers()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new FormPass());
|
||||
|
||||
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||
$extDefinition->setPublic(true);
|
||||
$extDefinition->setArguments([
|
||||
new Reference('service_container'),
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
]);
|
||||
|
||||
$definition1 = new Definition('stdClass');
|
||||
$definition1->addTag('form.type_guesser');
|
||||
$definition2 = new Definition('stdClass');
|
||||
$definition2->addTag('form.type_guesser');
|
||||
|
||||
$container->setDefinition('form.extension', $extDefinition);
|
||||
$container->setDefinition('my.guesser1', $definition1);
|
||||
$container->setDefinition('my.guesser2', $definition2);
|
||||
|
||||
$container->compile();
|
||||
|
||||
$extDefinition = $container->getDefinition('form.extension');
|
||||
|
||||
$this->assertSame([
|
||||
'my.guesser1',
|
||||
'my.guesser2',
|
||||
], $extDefinition->getArgument(3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider privateTaggedServicesProvider
|
||||
*/
|
||||
public function testPrivateTaggedServices($id, $tagName)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new FormPass());
|
||||
|
||||
$extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension');
|
||||
$extDefinition->setArguments([
|
||||
new Reference('service_container'),
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
]);
|
||||
|
||||
$container->setDefinition('form.extension', $extDefinition);
|
||||
$container->register($id, 'stdClass')->setPublic(false)->addTag($tagName, ['extended_type' => 'Foo']);
|
||||
|
||||
$container->compile();
|
||||
$this->assertTrue($container->getDefinition($id)->isPublic());
|
||||
}
|
||||
|
||||
public function privateTaggedServicesProvider()
|
||||
{
|
||||
return [
|
||||
['my.type', 'form.type'],
|
||||
['my.type_extension', 'form.type_extension'],
|
||||
['my.guesser', 'form.type_guesser'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class LoggingTranslatorPassTest extends TestCase
|
||||
{
|
||||
public function testProcess()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('translator.logging', true);
|
||||
$container->setParameter('translator.class', 'Symfony\Component\Translation\Translator');
|
||||
$container->register('monolog.logger');
|
||||
$container->setAlias('logger', 'monolog.logger');
|
||||
$container->register('translator.default', '%translator.class%');
|
||||
$container->register('translator.logging', '%translator.class%');
|
||||
$container->setAlias('translator', 'translator.default');
|
||||
$translationWarmerDefinition = $container->register('translation.warmer')
|
||||
->addArgument(new Reference('translator'))
|
||||
->addTag('container.service_subscriber', ['id' => 'translator'])
|
||||
->addTag('container.service_subscriber', ['id' => 'foo']);
|
||||
|
||||
$pass = new LoggingTranslatorPass();
|
||||
$pass->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
['container.service_subscriber' => [
|
||||
['id' => 'foo'],
|
||||
['key' => 'translator', 'id' => 'translator.logging.inner'],
|
||||
]],
|
||||
$translationWarmerDefinition->getTags()
|
||||
);
|
||||
}
|
||||
|
||||
public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('identity_translator');
|
||||
$container->setAlias('translator', 'identity_translator');
|
||||
|
||||
$definitionsBefore = \count($container->getDefinitions());
|
||||
$aliasesBefore = \count($container->getAliases());
|
||||
|
||||
$pass = new LoggingTranslatorPass();
|
||||
$pass->process($container);
|
||||
|
||||
// the container is untouched (i.e. no new definitions or aliases)
|
||||
$this->assertCount($definitionsBefore, $container->getDefinitions());
|
||||
$this->assertCount($aliasesBefore, $container->getAliases());
|
||||
}
|
||||
|
||||
public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('monolog.logger');
|
||||
$container->setAlias('logger', 'monolog.logger');
|
||||
|
||||
$definitionsBefore = \count($container->getDefinitions());
|
||||
$aliasesBefore = \count($container->getAliases());
|
||||
|
||||
$pass = new LoggingTranslatorPass();
|
||||
$pass->process($container);
|
||||
|
||||
// the container is untouched (i.e. no new definitions or aliases)
|
||||
$this->assertCount($definitionsBefore, $container->getDefinitions());
|
||||
$this->assertCount($aliasesBefore, $container->getAliases());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
class ProfilerPassTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Tests that collectors that specify a template but no "id" will throw
|
||||
* an exception (both are needed if the template is specified).
|
||||
*
|
||||
* Thus, a fully-valid tag looks something like this:
|
||||
*
|
||||
* <tag name="data_collector" template="YourBundle:Collector:templatename" id="your_collector_name" />
|
||||
*/
|
||||
public function testTemplateNoIdThrowsException()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$builder = new ContainerBuilder();
|
||||
$builder->register('profiler', 'ProfilerClass');
|
||||
$builder->register('my_collector_service')
|
||||
->addTag('data_collector', ['template' => 'foo']);
|
||||
|
||||
$profilerPass = new ProfilerPass();
|
||||
$profilerPass->process($builder);
|
||||
}
|
||||
|
||||
public function testValidCollector()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$profilerDefinition = $container->register('profiler', 'ProfilerClass');
|
||||
$container->register('my_collector_service')
|
||||
->addTag('data_collector', ['template' => 'foo', 'id' => 'my_collector']);
|
||||
|
||||
$profilerPass = new ProfilerPass();
|
||||
$profilerPass->process($container);
|
||||
|
||||
$this->assertSame(['my_collector_service' => ['my_collector', 'foo']], $container->getParameter('data_collector.templates'));
|
||||
|
||||
// grab the method calls off of the "profiler" definition
|
||||
$methodCalls = $profilerDefinition->getMethodCalls();
|
||||
$this->assertCount(1, $methodCalls);
|
||||
$this->assertEquals('add', $methodCalls[0][0]); // grab the method part of the first call
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class PropertyInfoPassTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTags
|
||||
*/
|
||||
public function testServicesAreOrderedAccordingToPriority($index, $tag)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$definition = $container->register('property_info')->setArguments([null, null, null, null]);
|
||||
$container->register('n2')->addTag($tag, ['priority' => 100]);
|
||||
$container->register('n1')->addTag($tag, ['priority' => 200]);
|
||||
$container->register('n3')->addTag($tag);
|
||||
|
||||
$propertyInfoPass = new PropertyInfoPass();
|
||||
$propertyInfoPass->process($container);
|
||||
|
||||
$expected = new IteratorArgument([
|
||||
new Reference('n1'),
|
||||
new Reference('n2'),
|
||||
new Reference('n3'),
|
||||
]);
|
||||
$this->assertEquals($expected, $definition->getArgument($index));
|
||||
}
|
||||
|
||||
public function provideTags()
|
||||
{
|
||||
return [
|
||||
[0, 'property_info.list_extractor'],
|
||||
[1, 'property_info.type_extractor'],
|
||||
[2, 'property_info.description_extractor'],
|
||||
[3, 'property_info.access_extractor'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testReturningEmptyArrayWhenNoService()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$propertyInfoExtractorDefinition = $container->register('property_info')
|
||||
->setArguments([[], [], [], []]);
|
||||
|
||||
$propertyInfoPass = new PropertyInfoPass();
|
||||
$propertyInfoPass->process($container);
|
||||
|
||||
$this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(0));
|
||||
$this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(1));
|
||||
$this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(2));
|
||||
$this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(3));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Tests for the SerializerPass class.
|
||||
*
|
||||
* @group legacy
|
||||
*
|
||||
* @author Javier Lopez <f12loalf@gmail.com>
|
||||
*/
|
||||
class SerializerPassTest extends TestCase
|
||||
{
|
||||
public function testThrowExceptionWhenNoNormalizers()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectExceptionMessage('You must tag at least one service as "serializer.normalizer" to use the "serializer" service');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('serializer');
|
||||
|
||||
$serializerPass = new SerializerPass();
|
||||
$serializerPass->process($container);
|
||||
}
|
||||
|
||||
public function testThrowExceptionWhenNoEncoders()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectExceptionMessage('You must tag at least one service as "serializer.encoder" to use the "serializer" service');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('serializer')
|
||||
->addArgument([])
|
||||
->addArgument([]);
|
||||
$container->register('normalizer')->addTag('serializer.normalizer');
|
||||
|
||||
$serializerPass = new SerializerPass();
|
||||
$serializerPass->process($container);
|
||||
}
|
||||
|
||||
public function testServicesAreOrderedAccordingToPriority()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$definition = $container->register('serializer')->setArguments([null, null]);
|
||||
$container->register('n2')->addTag('serializer.normalizer', ['priority' => 100])->addTag('serializer.encoder', ['priority' => 100]);
|
||||
$container->register('n1')->addTag('serializer.normalizer', ['priority' => 200])->addTag('serializer.encoder', ['priority' => 200]);
|
||||
$container->register('n3')->addTag('serializer.normalizer')->addTag('serializer.encoder');
|
||||
|
||||
$serializerPass = new SerializerPass();
|
||||
$serializerPass->process($container);
|
||||
|
||||
$expected = [
|
||||
new Reference('n1'),
|
||||
new Reference('n2'),
|
||||
new Reference('n3'),
|
||||
];
|
||||
$this->assertEquals($expected, $definition->getArgument(0));
|
||||
$this->assertEquals($expected, $definition->getArgument(1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TranslatorPassTest extends TestCase
|
||||
{
|
||||
public function testValidCollector()
|
||||
{
|
||||
$loader = (new Definition())
|
||||
->addTag('translation.loader', ['alias' => 'xliff', 'legacy-alias' => 'xlf']);
|
||||
|
||||
$translator = (new Definition())
|
||||
->setArguments([null, null, null, null]);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->setDefinition('translator.default', $translator);
|
||||
$container->setDefinition('translation.loader', $loader);
|
||||
|
||||
$pass = new TranslatorPass();
|
||||
$pass->process($container);
|
||||
|
||||
$expected = (new Definition())
|
||||
->addTag('translation.loader', ['alias' => 'xliff', 'legacy-alias' => 'xlf'])
|
||||
->addMethodCall('addLoader', ['xliff', new Reference('translation.loader')])
|
||||
->addMethodCall('addLoader', ['xlf', new Reference('translation.loader')])
|
||||
;
|
||||
$this->assertEquals($expected, $loader);
|
||||
|
||||
$this->assertSame(['translation.loader' => ['xliff', 'xlf']], $translator->getArgument(3));
|
||||
|
||||
$expected = ['translation.loader' => new ServiceClosureArgument(new Reference('translation.loader'))];
|
||||
$this->assertEquals($expected, $container->getDefinition((string) $translator->getArgument(0))->getArgument(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
class UnusedTagsPassTest extends TestCase
|
||||
{
|
||||
public function testProcess()
|
||||
{
|
||||
$pass = new UnusedTagsPass();
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo')
|
||||
->addTag('kenrel.event_subscriber');
|
||||
$container->register('bar')
|
||||
->addTag('kenrel.event_subscriber');
|
||||
|
||||
$pass->process($container);
|
||||
|
||||
$this->assertSame([sprintf('%s: Tag "kenrel.event_subscriber" was defined on service(s) "foo", "bar", but was never used. Did you mean "kernel.event_subscriber"?', UnusedTagsPass::class)], $container->getCompiler()->getLog());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Security\Core\Role\RoleHierarchy;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class WorkflowGuardListenerPassTest extends TestCase
|
||||
{
|
||||
private $container;
|
||||
private $compilerPass;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->container = new ContainerBuilder();
|
||||
$this->compilerPass = new WorkflowGuardListenerPass();
|
||||
}
|
||||
|
||||
public function testNoExeptionIfParameterIsNotSet()
|
||||
{
|
||||
$this->compilerPass->process($this->container);
|
||||
|
||||
$this->assertFalse($this->container->hasParameter('workflow.has_guard_listeners'));
|
||||
}
|
||||
|
||||
public function testNoExeptionIfAllDependenciesArePresent()
|
||||
{
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
|
||||
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
|
||||
$this->container->register('security.role_hierarchy', RoleHierarchy::class);
|
||||
$this->container->register('validator', ValidatorInterface::class);
|
||||
|
||||
$this->compilerPass->process($this->container);
|
||||
|
||||
$this->assertFalse($this->container->hasParameter('workflow.has_guard_listeners'));
|
||||
}
|
||||
|
||||
public function testExceptionIfTheTokenStorageServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
|
||||
$this->expectExceptionMessage('The "security.token_storage" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
|
||||
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
|
||||
$this->container->register('security.role_hierarchy', RoleHierarchy::class);
|
||||
|
||||
$this->compilerPass->process($this->container);
|
||||
}
|
||||
|
||||
public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
|
||||
$this->expectExceptionMessage('The "security.authorization_checker" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
|
||||
$this->container->register('security.role_hierarchy', RoleHierarchy::class);
|
||||
|
||||
$this->compilerPass->process($this->container);
|
||||
}
|
||||
|
||||
public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
|
||||
$this->expectExceptionMessage('The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
|
||||
$this->container->register('security.role_hierarchy', RoleHierarchy::class);
|
||||
|
||||
$this->compilerPass->process($this->container);
|
||||
}
|
||||
|
||||
public function testExceptionIfTheRoleHierarchyServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
|
||||
$this->expectExceptionMessage('The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
|
||||
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
|
||||
|
||||
$this->compilerPass->process($this->container);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,496 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
|
||||
use Symfony\Bundle\FullStack;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
public function testDefaultConfig()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(true), [['secret' => 's3cr3t']]);
|
||||
|
||||
$this->assertEquals(
|
||||
array_merge(['secret' => 's3cr3t', 'trusted_hosts' => []], self::getBundleDefaultConfig()),
|
||||
$config
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoNoDuplicateDefaultFormResources()
|
||||
{
|
||||
$input = ['templating' => [
|
||||
'form' => ['resources' => ['FrameworkBundle:Form']],
|
||||
'engines' => ['php'],
|
||||
]];
|
||||
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(true), [$input]);
|
||||
|
||||
$this->assertEquals(['FrameworkBundle:Form'], $config['templating']['form']['resources']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "framework.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.
|
||||
*/
|
||||
public function testTrustedProxiesSetToNullIsDeprecated()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$processor->processConfiguration($configuration, [['trusted_proxies' => null]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "framework.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.
|
||||
*/
|
||||
public function testTrustedProxiesSetToEmptyArrayIsDeprecated()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$processor->processConfiguration($configuration, [['trusted_proxies' => []]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "framework.trusted_proxies" configuration key has been deprecated in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.
|
||||
*/
|
||||
public function testTrustedProxiesSetToNonEmptyArrayIsInvalid()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$processor->processConfiguration($configuration, [['trusted_proxies' => ['127.0.0.1']]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider getTestValidSessionName
|
||||
*/
|
||||
public function testValidSessionName($sessionName)
|
||||
{
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(
|
||||
new Configuration(true),
|
||||
[['session' => ['name' => $sessionName]]]
|
||||
);
|
||||
|
||||
$this->assertEquals($sessionName, $config['session']['name']);
|
||||
}
|
||||
|
||||
public function getTestValidSessionName()
|
||||
{
|
||||
return [
|
||||
[null],
|
||||
['PHPSESSID'],
|
||||
['a&b'],
|
||||
[',_-!@#$%^*(){}:<>/?'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestInvalidSessionName
|
||||
*/
|
||||
public function testInvalidSessionName($sessionName)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
|
||||
$processor = new Processor();
|
||||
$processor->processConfiguration(
|
||||
new Configuration(true),
|
||||
[['session' => ['name' => $sessionName]]]
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestInvalidSessionName()
|
||||
{
|
||||
return [
|
||||
['a.b'],
|
||||
['a['],
|
||||
['a[]'],
|
||||
['a[b]'],
|
||||
['a=b'],
|
||||
['a+b'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestValidTrustedProxiesData
|
||||
* @group legacy
|
||||
*/
|
||||
public function testValidTrustedProxies($trustedProxies, $processedProxies)
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$config = $processor->processConfiguration($configuration, [[
|
||||
'secret' => 's3cr3t',
|
||||
'trusted_proxies' => $trustedProxies,
|
||||
]]);
|
||||
|
||||
$this->assertEquals($processedProxies, $config['trusted_proxies']);
|
||||
}
|
||||
|
||||
public function getTestValidTrustedProxiesData()
|
||||
{
|
||||
return [
|
||||
[['127.0.0.1'], ['127.0.0.1']],
|
||||
[['::1'], ['::1']],
|
||||
[['127.0.0.1', '::1'], ['127.0.0.1', '::1']],
|
||||
[null, []],
|
||||
[false, []],
|
||||
[[], []],
|
||||
[['10.0.0.0/8'], ['10.0.0.0/8']],
|
||||
[['::ffff:0:0/96'], ['::ffff:0:0/96']],
|
||||
[['0.0.0.0/0'], ['0.0.0.0/0']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testInvalidTypeTrustedProxies()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$processor->processConfiguration($configuration, [
|
||||
[
|
||||
'secret' => 's3cr3t',
|
||||
'trusted_proxies' => 'Not an IP address',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testInvalidValueTrustedProxies()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
|
||||
$processor->processConfiguration($configuration, [
|
||||
[
|
||||
'secret' => 's3cr3t',
|
||||
'trusted_proxies' => ['Not an IP address'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAssetsCanBeEnabled()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$config = $processor->processConfiguration($configuration, [['assets' => null]]);
|
||||
|
||||
$defaultConfig = [
|
||||
'enabled' => true,
|
||||
'version_strategy' => null,
|
||||
'version' => null,
|
||||
'version_format' => '%%s?%%s',
|
||||
'base_path' => '',
|
||||
'base_urls' => [],
|
||||
'packages' => [],
|
||||
'json_manifest_path' => null,
|
||||
];
|
||||
|
||||
$this->assertEquals($defaultConfig, $config['assets']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidAssetsPackageNameConfigurationTests
|
||||
*/
|
||||
public function testValidAssetsPackageNameConfiguration($packageName)
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$config = $processor->processConfiguration($configuration, [
|
||||
[
|
||||
'assets' => [
|
||||
'packages' => [
|
||||
$packageName => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertArrayHasKey($packageName, $config['assets']['packages']);
|
||||
}
|
||||
|
||||
public function provideValidAssetsPackageNameConfigurationTests()
|
||||
{
|
||||
return [
|
||||
['foobar'],
|
||||
['foo-bar'],
|
||||
['foo_bar'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidAssetConfigurationTests
|
||||
*/
|
||||
public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage)
|
||||
{
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$processor->processConfiguration($configuration, [
|
||||
[
|
||||
'assets' => $assetConfig,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function provideInvalidAssetConfigurationTests()
|
||||
{
|
||||
// helper to turn config into embedded package config
|
||||
$createPackageConfig = function (array $packageConfig) {
|
||||
return [
|
||||
'base_urls' => '//example.com',
|
||||
'version' => 1,
|
||||
'packages' => [
|
||||
'foo' => $packageConfig,
|
||||
],
|
||||
];
|
||||
};
|
||||
|
||||
$config = [
|
||||
'version' => 1,
|
||||
'version_strategy' => 'foo',
|
||||
];
|
||||
yield [$config, 'You cannot use both "version_strategy" and "version" at the same time under "assets".'];
|
||||
yield [$createPackageConfig($config), 'You cannot use both "version_strategy" and "version" at the same time under "assets" packages.'];
|
||||
|
||||
$config = [
|
||||
'json_manifest_path' => '/foo.json',
|
||||
'version_strategy' => 'foo',
|
||||
];
|
||||
yield [$config, 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".'];
|
||||
yield [$createPackageConfig($config), 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.'];
|
||||
|
||||
$config = [
|
||||
'json_manifest_path' => '/foo.json',
|
||||
'version' => '1',
|
||||
];
|
||||
yield [$config, 'You cannot use both "version" and "json_manifest_path" at the same time under "assets".'];
|
||||
yield [$createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidLockConfigurationTests
|
||||
*/
|
||||
public function testValidLockConfiguration($lockConfig, $processedConfig)
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$config = $processor->processConfiguration($configuration, [
|
||||
[
|
||||
'lock' => $lockConfig,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertArrayHasKey('lock', $config);
|
||||
|
||||
$this->assertEquals($processedConfig, $config['lock']);
|
||||
}
|
||||
|
||||
public function provideValidLockConfigurationTests()
|
||||
{
|
||||
yield [null, ['enabled' => true, 'resources' => ['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]]];
|
||||
|
||||
yield ['flock', ['enabled' => true, 'resources' => ['default' => ['flock']]]];
|
||||
yield [['flock', 'semaphore'], ['enabled' => true, 'resources' => ['default' => ['flock', 'semaphore']]]];
|
||||
yield [['foo' => 'flock', 'bar' => 'semaphore'], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
|
||||
yield [['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore'], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
||||
yield [['default' => 'flock'], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
|
||||
|
||||
yield [['enabled' => false, 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
|
||||
yield [['enabled' => false, ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['default' => ['flock', 'semaphore']]]];
|
||||
yield [['enabled' => false, 'foo' => 'flock', 'bar' => 'semaphore'], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
|
||||
yield [['enabled' => false, 'foo' => ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore']]]];
|
||||
yield [['enabled' => false, 'default' => 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
|
||||
|
||||
yield [['resources' => 'flock'], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
|
||||
yield [['resources' => ['flock', 'semaphore']], ['enabled' => true, 'resources' => ['default' => ['flock', 'semaphore']]]];
|
||||
yield [['resources' => ['foo' => 'flock', 'bar' => 'semaphore']], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
|
||||
yield [['resources' => ['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore']], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
||||
yield [['resources' => ['default' => 'flock']], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
|
||||
|
||||
yield [['enabled' => false, 'resources' => 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
|
||||
yield [['enabled' => false, 'resources' => ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['default' => ['flock', 'semaphore']]]];
|
||||
yield [['enabled' => false, 'resources' => ['foo' => 'flock', 'bar' => 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
|
||||
yield [['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
||||
yield [['enabled' => false, 'resources' => ['default' => 'flock']], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
|
||||
|
||||
// xml
|
||||
|
||||
yield [['resource' => ['flock']], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
|
||||
yield [['resource' => ['flock', ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['default' => ['flock'], 'foo' => ['semaphore']]]];
|
||||
yield [['resource' => [['name' => 'foo', 'value' => 'flock']]], ['enabled' => true, 'resources' => ['foo' => ['flock']]]];
|
||||
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore']]]];
|
||||
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
|
||||
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
||||
|
||||
yield [['enabled' => false, 'resource' => ['flock']], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
|
||||
yield [['enabled' => false, 'resource' => ['flock', ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['default' => ['flock'], 'foo' => ['semaphore']]]];
|
||||
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock']]], ['enabled' => false, 'resources' => ['foo' => ['flock']]]];
|
||||
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore']]]];
|
||||
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
|
||||
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
||||
}
|
||||
|
||||
protected static function getBundleDefaultConfig()
|
||||
{
|
||||
return [
|
||||
'http_method_override' => true,
|
||||
'trusted_proxies' => [],
|
||||
'ide' => null,
|
||||
'default_locale' => 'en',
|
||||
'csrf_protection' => [
|
||||
'enabled' => false,
|
||||
],
|
||||
'form' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'csrf_protection' => [
|
||||
'enabled' => null, // defaults to csrf_protection.enabled
|
||||
'field_name' => '_token',
|
||||
],
|
||||
],
|
||||
'esi' => ['enabled' => false],
|
||||
'ssi' => ['enabled' => false],
|
||||
'fragments' => [
|
||||
'enabled' => false,
|
||||
'path' => '/_fragment',
|
||||
],
|
||||
'profiler' => [
|
||||
'enabled' => false,
|
||||
'only_exceptions' => false,
|
||||
'only_master_requests' => false,
|
||||
'dsn' => 'file:%kernel.cache_dir%/profiler',
|
||||
'collect' => true,
|
||||
'matcher' => [
|
||||
'enabled' => false,
|
||||
'ips' => [],
|
||||
],
|
||||
],
|
||||
'translator' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'fallbacks' => ['en'],
|
||||
'logging' => true,
|
||||
'formatter' => 'translator.formatter.default',
|
||||
'paths' => [],
|
||||
'default_path' => '%kernel.project_dir%/translations',
|
||||
],
|
||||
'validation' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'enable_annotations' => !class_exists(FullStack::class),
|
||||
'static_method' => ['loadValidatorMetadata'],
|
||||
'translation_domain' => 'validators',
|
||||
'strict_email' => false,
|
||||
'mapping' => [
|
||||
'paths' => [],
|
||||
],
|
||||
],
|
||||
'annotations' => [
|
||||
'cache' => 'php_array',
|
||||
'file_cache_dir' => '%kernel.cache_dir%/annotations',
|
||||
'debug' => true,
|
||||
'enabled' => true,
|
||||
],
|
||||
'serializer' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'enable_annotations' => !class_exists(FullStack::class),
|
||||
'mapping' => ['paths' => []],
|
||||
],
|
||||
'property_access' => [
|
||||
'magic_call' => false,
|
||||
'throw_exception_on_invalid_index' => false,
|
||||
],
|
||||
'property_info' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
],
|
||||
'router' => [
|
||||
'enabled' => false,
|
||||
'http_port' => 80,
|
||||
'https_port' => 443,
|
||||
'strict_requirements' => true,
|
||||
],
|
||||
'session' => [
|
||||
'enabled' => false,
|
||||
'storage_id' => 'session.storage.native',
|
||||
'handler_id' => 'session.handler.native_file',
|
||||
'cookie_httponly' => true,
|
||||
'gc_probability' => 1,
|
||||
'save_path' => '%kernel.cache_dir%/sessions',
|
||||
'metadata_update_threshold' => '0',
|
||||
'use_strict_mode' => true,
|
||||
],
|
||||
'request' => [
|
||||
'enabled' => false,
|
||||
'formats' => [],
|
||||
],
|
||||
'templating' => [
|
||||
'enabled' => false,
|
||||
'hinclude_default_template' => null,
|
||||
'form' => [
|
||||
'resources' => ['FrameworkBundle:Form'],
|
||||
],
|
||||
'engines' => [],
|
||||
'loaders' => [],
|
||||
],
|
||||
'assets' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'version_strategy' => null,
|
||||
'version' => null,
|
||||
'version_format' => '%%s?%%s',
|
||||
'base_path' => '',
|
||||
'base_urls' => [],
|
||||
'packages' => [],
|
||||
'json_manifest_path' => null,
|
||||
],
|
||||
'cache' => [
|
||||
'pools' => [],
|
||||
'app' => 'cache.adapter.filesystem',
|
||||
'system' => 'cache.adapter.system',
|
||||
'directory' => '%kernel.cache_dir%/pools',
|
||||
'default_redis_provider' => 'redis://localhost',
|
||||
'default_memcached_provider' => 'memcached://localhost',
|
||||
],
|
||||
'workflows' => [
|
||||
'enabled' => false,
|
||||
'workflows' => [],
|
||||
],
|
||||
'php_errors' => [
|
||||
'log' => true,
|
||||
'throw' => true,
|
||||
],
|
||||
'web_link' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
],
|
||||
'lock' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'resources' => [
|
||||
'default' => [
|
||||
class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class CustomPathBundle extends Bundle
|
||||
{
|
||||
public function getPath()
|
||||
{
|
||||
return __DIR__.'/..';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class TestBundle extends Bundle
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'assets' => [
|
||||
'version' => 'SomeVersionScheme',
|
||||
'base_urls' => 'http://cdn.example.com',
|
||||
'version_format' => '%%s?version=%%s',
|
||||
'packages' => [
|
||||
'images_path' => [
|
||||
'base_path' => '/foo',
|
||||
],
|
||||
'images' => [
|
||||
'version' => '1.0.0',
|
||||
'base_urls' => ['http://images1.example.com', 'http://images2.example.com'],
|
||||
],
|
||||
'foo' => [
|
||||
'version' => '1.0.0',
|
||||
'version_format' => '%%s-%%s',
|
||||
],
|
||||
'bar' => [
|
||||
'base_urls' => ['https://bar2.example.com'],
|
||||
],
|
||||
'bar_version_strategy' => [
|
||||
'base_urls' => ['https://bar2.example.com'],
|
||||
'version_strategy' => 'assets.custom_version_strategy',
|
||||
],
|
||||
'json_manifest_strategy' => [
|
||||
'json_manifest_path' => '/path/to/manifest.json',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'assets' => [
|
||||
'enabled' => false,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'assets' => [
|
||||
'version_strategy' => 'assets.custom_version_strategy',
|
||||
'base_urls' => 'http://cdn.example.com',
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'cache' => [
|
||||
'pools' => [
|
||||
'cache.foo' => [
|
||||
'adapter' => 'cache.adapter.apcu',
|
||||
'default_lifetime' => 30,
|
||||
],
|
||||
'cache.bar' => [
|
||||
'adapter' => 'cache.adapter.doctrine',
|
||||
'default_lifetime' => 5,
|
||||
'provider' => 'app.doctrine_cache_provider',
|
||||
],
|
||||
'cache.baz' => [
|
||||
'adapter' => 'cache.adapter.filesystem',
|
||||
'default_lifetime' => 7,
|
||||
],
|
||||
'cache.foobar' => [
|
||||
'adapter' => 'cache.adapter.psr6',
|
||||
'default_lifetime' => 10,
|
||||
'provider' => 'app.cache_pool',
|
||||
],
|
||||
'cache.def' => [
|
||||
'default_lifetime' => 11,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$container->setParameter('env(REDIS_URL)', 'redis://paas.com');
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'cache' => [
|
||||
'default_redis_provider' => '%env(REDIS_URL)%',
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'csrf_protection' => true,
|
||||
'form' => true,
|
||||
'session' => [
|
||||
'handler_id' => null,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'csrf_protection' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', []);
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'fragments' => [
|
||||
'enabled' => false,
|
||||
],
|
||||
'esi' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
'ssi' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'esi' => [
|
||||
'enabled' => false,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'form' => [
|
||||
'csrf_protection' => [
|
||||
'enabled' => false,
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'secret' => 's3cr3t',
|
||||
'default_locale' => 'fr',
|
||||
'csrf_protection' => true,
|
||||
'form' => [
|
||||
'csrf_protection' => [
|
||||
'field_name' => '_csrf',
|
||||
],
|
||||
],
|
||||
'http_method_override' => false,
|
||||
'esi' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
'ssi' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
'profiler' => [
|
||||
'only_exceptions' => true,
|
||||
'enabled' => false,
|
||||
],
|
||||
'router' => [
|
||||
'resource' => '%kernel.project_dir%/config/routing.xml',
|
||||
'type' => 'xml',
|
||||
],
|
||||
'session' => [
|
||||
'storage_id' => 'session.storage.native',
|
||||
'handler_id' => 'session.handler.native_file',
|
||||
'name' => '_SYMFONY',
|
||||
'cookie_lifetime' => 86400,
|
||||
'cookie_path' => '/',
|
||||
'cookie_domain' => 'example.com',
|
||||
'cookie_secure' => true,
|
||||
'cookie_httponly' => false,
|
||||
'use_cookies' => true,
|
||||
'gc_maxlifetime' => 90000,
|
||||
'gc_divisor' => 108,
|
||||
'gc_probability' => 1,
|
||||
'save_path' => '/path/to/sessions',
|
||||
],
|
||||
'templating' => [
|
||||
'cache' => '/path/to/cache',
|
||||
'engines' => ['php', 'twig'],
|
||||
'loader' => ['loader.foo', 'loader.bar'],
|
||||
'form' => [
|
||||
'resources' => ['theme1', 'theme2'],
|
||||
],
|
||||
'hinclude_default_template' => 'global_hinclude_template',
|
||||
],
|
||||
'assets' => [
|
||||
'version' => 'v1',
|
||||
],
|
||||
'translator' => [
|
||||
'enabled' => true,
|
||||
'fallback' => 'fr',
|
||||
'paths' => ['%kernel.project_dir%/Fixtures/translations'],
|
||||
],
|
||||
'validation' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
'annotations' => [
|
||||
'cache' => 'file',
|
||||
'debug' => true,
|
||||
'file_cache_dir' => '%kernel.cache_dir%/annotations',
|
||||
],
|
||||
'serializer' => [
|
||||
'enabled' => true,
|
||||
'enable_annotations' => true,
|
||||
'name_converter' => 'serializer.name_converter.camel_case_to_snake_case',
|
||||
'circular_reference_handler' => 'my.circular.reference.handler',
|
||||
],
|
||||
'property_info' => true,
|
||||
'ide' => 'file%%link%%format',
|
||||
'request' => [
|
||||
'formats' => [
|
||||
'csv' => [
|
||||
'text/csv',
|
||||
'text/plain',
|
||||
],
|
||||
'pdf' => 'application/pdf',
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'php_errors' => [
|
||||
'log' => false,
|
||||
'throw' => false,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'php_errors' => [
|
||||
'log' => true,
|
||||
'throw' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'profiler' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'property_access' => [
|
||||
'magic_call' => true,
|
||||
'throw_exception_on_invalid_index' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'property_info' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'request' => [
|
||||
'formats' => [],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => [
|
||||
'enabled' => false,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => [
|
||||
'enabled' => true,
|
||||
'cache' => 'foo',
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'annotations' => ['enabled' => true],
|
||||
'serializer' => [
|
||||
'enable_annotations' => true,
|
||||
'mapping' => [
|
||||
'paths' => [
|
||||
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files',
|
||||
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml',
|
||||
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'session' => [
|
||||
'handler_id' => null,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'ssi' => [
|
||||
'enabled' => false,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'templating' => false,
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'templating' => [
|
||||
'engines' => ['php', 'twig'],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'assets' => false,
|
||||
'templating' => [
|
||||
'engines' => ['php'],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'translator' => false,
|
||||
'templating' => [
|
||||
'engines' => ['php'],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'translator' => true,
|
||||
'templating' => [
|
||||
'engines' => ['php'],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'translator' => [
|
||||
'fallbacks' => ['en', 'fr'],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'secret' => 's3cr3t',
|
||||
'validation' => [
|
||||
'enabled' => true,
|
||||
'enable_annotations' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'validation' => [
|
||||
'mapping' => [
|
||||
'paths' => [
|
||||
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files',
|
||||
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml',
|
||||
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'secret' => 's3cr3t',
|
||||
'validation' => [
|
||||
'enabled' => true,
|
||||
'static_method' => ['loadFoo', 'loadBar'],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'secret' => 's3cr3t',
|
||||
'validation' => [
|
||||
'enabled' => true,
|
||||
'static_method' => false,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'validation' => [
|
||||
'strict_email' => true,
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'validation' => [
|
||||
'translation_domain' => 'messages',
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'web_link' => ['enabled' => true],
|
||||
]);
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'my_workflow' => [
|
||||
'marking_store' => [
|
||||
'arguments' => ['a', 'b'],
|
||||
'service' => 'workflow_service',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => [
|
||||
'first',
|
||||
],
|
||||
'to' => [
|
||||
'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'article' => [
|
||||
'type' => 'workflow',
|
||||
'marking_store' => [
|
||||
'type' => 'multiple_state',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'initial_place' => 'draft',
|
||||
'places' => [
|
||||
'draft',
|
||||
'wait_for_journalist',
|
||||
'approved_by_journalist',
|
||||
'wait_for_spellchecker',
|
||||
'approved_by_spellchecker',
|
||||
'published',
|
||||
],
|
||||
'transitions' => [
|
||||
'request_review' => [
|
||||
'from' => 'draft',
|
||||
'to' => ['wait_for_journalist', 'wait_for_spellchecker'],
|
||||
],
|
||||
'journalist_approval' => [
|
||||
'from' => 'wait_for_journalist',
|
||||
'to' => 'approved_by_journalist',
|
||||
],
|
||||
'spellchecker_approval' => [
|
||||
'from' => 'wait_for_spellchecker',
|
||||
'to' => 'approved_by_spellchecker',
|
||||
],
|
||||
'publish' => [
|
||||
'from' => ['approved_by_journalist', 'approved_by_spellchecker'],
|
||||
'to' => 'published',
|
||||
'guard' => '!!true',
|
||||
],
|
||||
'publish_editor_in_chief' => [
|
||||
'name' => 'publish',
|
||||
'from' => 'draft',
|
||||
'to' => 'published',
|
||||
'guard' => '!!false',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'article' => [
|
||||
'type' => 'workflow',
|
||||
'marking_store' => [
|
||||
'type' => 'multiple_state',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'initial_place' => 'draft',
|
||||
'places' => [
|
||||
'draft',
|
||||
'wait_for_journalist',
|
||||
'approved_by_journalist',
|
||||
'wait_for_spellchecker',
|
||||
'approved_by_spellchecker',
|
||||
'published',
|
||||
],
|
||||
'transitions' => [
|
||||
'request_review' => [
|
||||
'from' => 'draft',
|
||||
'to' => ['wait_for_journalist', 'wait_for_spellchecker'],
|
||||
],
|
||||
'journalist_approval' => [
|
||||
'from' => 'wait_for_journalist',
|
||||
'to' => 'approved_by_journalist',
|
||||
],
|
||||
'spellchecker_approval' => [
|
||||
'from' => 'wait_for_spellchecker',
|
||||
'to' => 'approved_by_spellchecker',
|
||||
],
|
||||
'publish' => [
|
||||
'from' => ['approved_by_journalist', 'approved_by_spellchecker'],
|
||||
'to' => 'published',
|
||||
],
|
||||
'publish_editor_in_chief' => [
|
||||
'name' => 'publish',
|
||||
'from' => 'draft',
|
||||
'to' => 'published',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'my_workflow' => [
|
||||
'marking_store' => [
|
||||
'type' => 'multiple_state',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'support_strategy' => 'foobar',
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => [
|
||||
'first',
|
||||
],
|
||||
'to' => [
|
||||
'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'my_workflow' => [
|
||||
'marking_store' => [
|
||||
'type' => 'multiple_state',
|
||||
'service' => 'workflow_service',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => [
|
||||
'first',
|
||||
],
|
||||
'to' => [
|
||||
'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'my_workflow' => [
|
||||
'marking_store' => [
|
||||
'type' => 'multiple_state',
|
||||
],
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => [
|
||||
'first',
|
||||
],
|
||||
'to' => [
|
||||
'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'article' => [
|
||||
'type' => 'workflow',
|
||||
'marking_store' => [
|
||||
'type' => 'multiple_state',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'initial_place' => 'draft',
|
||||
'places' => [
|
||||
'draft',
|
||||
'wait_for_journalist',
|
||||
'approved_by_journalist',
|
||||
'wait_for_spellchecker',
|
||||
'approved_by_spellchecker',
|
||||
'published',
|
||||
],
|
||||
'transitions' => [
|
||||
'request_review' => [
|
||||
'from' => 'draft',
|
||||
'to' => ['wait_for_journalist', 'wait_for_spellchecker'],
|
||||
],
|
||||
'journalist_approval' => [
|
||||
'from' => 'wait_for_journalist',
|
||||
'to' => 'approved_by_journalist',
|
||||
],
|
||||
'spellchecker_approval' => [
|
||||
'from' => 'wait_for_spellchecker',
|
||||
'to' => 'approved_by_spellchecker',
|
||||
],
|
||||
'publish' => [
|
||||
'from' => ['approved_by_journalist', 'approved_by_spellchecker'],
|
||||
'to' => 'published',
|
||||
],
|
||||
],
|
||||
],
|
||||
'pull_request' => [
|
||||
'type' => 'state_machine',
|
||||
'marking_store' => [
|
||||
'type' => 'single_state',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'initial_place' => 'start',
|
||||
'places' => [
|
||||
'start',
|
||||
'coding',
|
||||
'travis',
|
||||
'review',
|
||||
'merged',
|
||||
'closed',
|
||||
],
|
||||
'transitions' => [
|
||||
'submit' => [
|
||||
'from' => 'start',
|
||||
'to' => 'travis',
|
||||
],
|
||||
'update' => [
|
||||
'from' => ['coding', 'travis', 'review'],
|
||||
'to' => 'travis',
|
||||
],
|
||||
'wait_for_review' => [
|
||||
'from' => 'travis',
|
||||
'to' => 'review',
|
||||
],
|
||||
'request_change' => [
|
||||
'from' => 'review',
|
||||
'to' => 'coding',
|
||||
],
|
||||
'accept' => [
|
||||
'from' => 'review',
|
||||
'to' => 'merged',
|
||||
],
|
||||
'reject' => [
|
||||
'from' => 'review',
|
||||
'to' => 'closed',
|
||||
],
|
||||
'reopen' => [
|
||||
'from' => 'closed',
|
||||
'to' => 'review',
|
||||
],
|
||||
],
|
||||
],
|
||||
'service_marking_store_workflow' => [
|
||||
'type' => 'workflow',
|
||||
'marking_store' => [
|
||||
'service' => 'workflow_service',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => 'first',
|
||||
'to' => 'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => null,
|
||||
]);
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'enabled' => true,
|
||||
'foo' => [
|
||||
'type' => 'workflow',
|
||||
'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'],
|
||||
'initial_place' => 'bar',
|
||||
'places' => ['bar', 'baz'],
|
||||
'transitions' => [
|
||||
'bar_baz' => [
|
||||
'from' => ['foo'],
|
||||
'to' => ['bar'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'enabled' => true,
|
||||
'workflows' => [
|
||||
'type' => 'workflow',
|
||||
'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'],
|
||||
'initial_place' => 'bar',
|
||||
'places' => ['bar', 'baz'],
|
||||
'transitions' => [
|
||||
'bar_baz' => [
|
||||
'from' => ['foo'],
|
||||
'to' => ['bar'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'missing_type' => [
|
||||
'marking_store' => [
|
||||
'service' => 'workflow_service',
|
||||
],
|
||||
'supports' => [
|
||||
\stdClass::class,
|
||||
],
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => 'first',
|
||||
'to' => 'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -0,0 +1,2 @@
|
||||
custom:
|
||||
paths: test
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:assets version="SomeVersionScheme" version-format="%%s?version=%%s">
|
||||
<framework:base-url>http://cdn.example.com</framework:base-url>
|
||||
<framework:package name="images_path" base-path="/foo" version-format="%%s-%%s" />
|
||||
<framework:package name="images" version="1.0.0">
|
||||
<framework:base-url>http://images1.example.com</framework:base-url>
|
||||
<framework:base-url>http://images2.example.com</framework:base-url>
|
||||
</framework:package>
|
||||
<framework:package name="foo" version="1.0.0" version-format="%%s-%%s" />
|
||||
<framework:package name="bar">
|
||||
<framework:base-url>https://bar2.example.com</framework:base-url>
|
||||
</framework:package>
|
||||
<framework:package name="bar_version_strategy" version-strategy="assets.custom_version_strategy">
|
||||
<framework:base-url>https://bar_version_strategy.example.com</framework:base-url>
|
||||
</framework:package>
|
||||
<framework:package name="json_manifest_strategy" json-manifest-path="/path/to/manifest.json" />
|
||||
</framework:assets>
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:assets enabled="false" />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:assets version-strategy="assets.custom_version_strategy">
|
||||
<framework:base-url>http://cdn.example.com</framework:base-url>
|
||||
</framework:assets>
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:cache>
|
||||
<framework:pool name="cache.foo" adapter="cache.adapter.apcu" default-lifetime="30" />
|
||||
<framework:pool name="cache.bar" adapter="cache.adapter.doctrine" default-lifetime="5" provider="app.doctrine_cache_provider" />
|
||||
<framework:pool name="cache.baz" adapter="cache.adapter.filesystem" default-lifetime="7" />
|
||||
<framework:pool name="cache.foobar" adapter="cache.adapter.psr6" default-lifetime="10" provider="app.cache_pool" />
|
||||
<framework:pool name="cache.def" default-lifetime="11" />
|
||||
</framework:cache>
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="env(REDIS_URL)">redis://paas.com</parameter>
|
||||
</parameters>
|
||||
|
||||
<framework:config>
|
||||
<framework:cache>
|
||||
<framework:default-redis-provider>%env(REDIS_URL)%</framework:default-redis-provider>
|
||||
</framework:cache>
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:csrf-protection />
|
||||
<framework:form />
|
||||
<framework:session />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:csrf-protection enabled="false" />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:csrf-protection />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config />
|
||||
</container>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:fragments enabled="false" />
|
||||
<framework:esi enabled="true" />
|
||||
<framework:ssi enabled="true" />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:esi enabled="false" />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:csrf-protection field-name="_custom" />
|
||||
<framework:session />
|
||||
<framework:form />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:csrf-protection field-name="_custom_form" />
|
||||
<framework:form />
|
||||
<framework:session />
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:form enabled="true">
|
||||
<framework:csrf-protection enabled="false" />
|
||||
</framework:form>
|
||||
</framework:config>
|
||||
</container>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config secret="s3cr3t" ide="file%%link%%format" default-locale="fr" http-method-override="false">
|
||||
<framework:csrf-protection />
|
||||
<framework:form>
|
||||
<framework:csrf-protection field-name="_csrf"/>
|
||||
</framework:form>
|
||||
<framework:esi enabled="true" />
|
||||
<framework:ssi enabled="true" />
|
||||
<framework:profiler only-exceptions="true" enabled="false" />
|
||||
<framework:router resource="%kernel.project_dir%/config/routing.xml" type="xml" />
|
||||
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="false" use-cookies="true" save-path="/path/to/sessions" />
|
||||
<framework:request>
|
||||
<framework:format name="csv">
|
||||
<framework:mime-type>text/csv</framework:mime-type>
|
||||
<framework:mime-type>text/plain</framework:mime-type>
|
||||
</framework:format>
|
||||
<framework:format name="pdf">
|
||||
<framework:mime-type>application/pdf</framework:mime-type>
|
||||
</framework:format>
|
||||
</framework:request>
|
||||
<framework:templating cache="/path/to/cache" hinclude-default-template="global_hinclude_template">
|
||||
<framework:loader>loader.foo</framework:loader>
|
||||
<framework:loader>loader.bar</framework:loader>
|
||||
<framework:engine>php</framework:engine>
|
||||
<framework:engine>twig</framework:engine>
|
||||
<framework:form>
|
||||
<framework:resource>theme1</framework:resource>
|
||||
<framework:resource>theme2</framework:resource>
|
||||
</framework:form>
|
||||
</framework:templating>
|
||||
<framework:assets version="v1" />
|
||||
<framework:translator enabled="true" fallback="fr" logging="true">
|
||||
<framework:path>%kernel.project_dir%/Fixtures/translations</framework:path>
|
||||
</framework:translator>
|
||||
<framework:validation enabled="true" />
|
||||
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
|
||||
<framework:serializer enabled="true" enable-annotations="true" name-converter="serializer.name_converter.camel_case_to_snake_case" circular-reference-handler="my.circular.reference.handler" />
|
||||
<framework:property-info />
|
||||
</framework:config>
|
||||
</container>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user