feature #22620 [FrameworkBundle][HttpKernel] Move httpkernel pass (lepiaf)
This PR was merged into the 3.4 branch.
Discussion
----------
[FrameworkBundle][HttpKernel] Move httpkernel pass
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | part of #21284
| License | MIT
| Doc PR | n/a
Move addcachearmer, addcacheclearer compiler pass to httpkernel
Commits
-------
83727c7e3d
[FrameworkBundle][HttpKernel] Move addcachearmer, addcacheclearer compiler pass
This commit is contained in:
commit
3981f9ba89
@ -38,6 +38,14 @@ FrameworkBundle
|
|||||||
will be removed in 4.0. Use the `--prefix` option with an empty string as value
|
will be removed in 4.0. Use the `--prefix` option with an empty string as value
|
||||||
instead (e.g. `--prefix=""`)
|
instead (e.g. `--prefix=""`)
|
||||||
|
|
||||||
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass`
|
||||||
|
class has been deprecated and will be removed in 4.0. Use the
|
||||||
|
`Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass` class instead.
|
||||||
|
|
||||||
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass`
|
||||||
|
class has been deprecated and will be removed in 4.0. Use the
|
||||||
|
`Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass` class instead.
|
||||||
|
|
||||||
Process
|
Process
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -348,6 +348,12 @@ FrameworkBundle
|
|||||||
* The `--no-prefix` option of the `translation:update` command has
|
* The `--no-prefix` option of the `translation:update` command has
|
||||||
been removed.
|
been removed.
|
||||||
|
|
||||||
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass` class has been removed.
|
||||||
|
Use the `Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass` class instead.
|
||||||
|
|
||||||
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass` class has been removed.
|
||||||
|
Use the `Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass` class instead.
|
||||||
|
|
||||||
HttpFoundation
|
HttpFoundation
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ CHANGELOG
|
|||||||
require symfony/stopwatch` in your `dev` environment.
|
require symfony/stopwatch` in your `dev` environment.
|
||||||
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
|
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
|
||||||
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
|
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
|
||||||
|
* Deprecated `AddCacheClearerPass`, use `Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass` instead.
|
||||||
|
* Deprecated `AddCacheWarmerPass`, use `Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass` instead.
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
@ -11,31 +11,17 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass instead.', AddCacheClearerPass::class), E_USER_DEPRECATED);
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass as BaseAddCacheClearerPass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the cache clearers.
|
* Registers the cache clearers.
|
||||||
*
|
*
|
||||||
|
* @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseAddCacheClearerPass instead}.
|
||||||
|
*
|
||||||
* @author Dustin Dobervich <ddobervich@gmail.com>
|
* @author Dustin Dobervich <ddobervich@gmail.com>
|
||||||
*/
|
*/
|
||||||
class AddCacheClearerPass implements CompilerPassInterface
|
class AddCacheClearerPass extends BaseAddCacheClearerPass
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function process(ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
if (!$container->hasDefinition('cache_clearer')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$clearers = array();
|
|
||||||
foreach ($container->findTaggedServiceIds('kernel.cache_clearer', true) as $id => $attributes) {
|
|
||||||
$clearers[] = new Reference($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$container->getDefinition('cache_clearer')->replaceArgument(0, $clearers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,34 +11,17 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass instead.', AddCacheWarmerPass::class), E_USER_DEPRECATED);
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass as BaseAddCacheWarmerPass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the cache warmers.
|
* Registers the cache warmers.
|
||||||
*
|
*
|
||||||
|
* @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseAddCacheWarmerPass instead}.
|
||||||
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class AddCacheWarmerPass implements CompilerPassInterface
|
class AddCacheWarmerPass extends BaseAddCacheWarmerPass
|
||||||
{
|
{
|
||||||
use PriorityTaggedServiceTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function process(ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
if (!$container->hasDefinition('cache_warmer')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$warmers = $this->findAndSortTaggedServices('kernel.cache_warmer', $container);
|
|
||||||
|
|
||||||
if (empty($warmers)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$container->getDefinition('cache_warmer')->replaceArgument(0, $warmers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
|
|||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
|
||||||
@ -30,6 +28,8 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumpe
|
|||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
||||||
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
|
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
|
||||||
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
||||||
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass;
|
||||||
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
|
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
|
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;
|
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;
|
||||||
|
@ -16,6 +16,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
class AddCacheWarmerPassTest extends TestCase
|
class AddCacheWarmerPassTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testThatCacheWarmersAreProcessedInPriorityOrder()
|
public function testThatCacheWarmersAreProcessedInPriorityOrder()
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
"symfony/config": "~3.3|~4.0",
|
"symfony/config": "~3.3|~4.0",
|
||||||
"symfony/event-dispatcher": "^3.3.1|~4.0",
|
"symfony/event-dispatcher": "^3.3.1|~4.0",
|
||||||
"symfony/http-foundation": "~3.3|~4.0",
|
"symfony/http-foundation": "~3.3|~4.0",
|
||||||
"symfony/http-kernel": "~3.3|~4.0",
|
"symfony/http-kernel": "~3.4|~4.0",
|
||||||
"symfony/polyfill-mbstring": "~1.0",
|
"symfony/polyfill-mbstring": "~1.0",
|
||||||
"symfony/filesystem": "~2.8|~3.0|~4.0",
|
"symfony/filesystem": "~2.8|~3.0|~4.0",
|
||||||
"symfony/finder": "~2.8|~3.0|~4.0",
|
"symfony/finder": "~2.8|~3.0|~4.0",
|
||||||
@ -66,6 +66,7 @@
|
|||||||
"symfony/asset": "<3.3",
|
"symfony/asset": "<3.3",
|
||||||
"symfony/console": "<3.3",
|
"symfony/console": "<3.3",
|
||||||
"symfony/form": "<3.3",
|
"symfony/form": "<3.3",
|
||||||
|
"symfony/http-kernel": "<3.4",
|
||||||
"symfony/property-info": "<3.3",
|
"symfony/property-info": "<3.3",
|
||||||
"symfony/serializer": "<3.3",
|
"symfony/serializer": "<3.3",
|
||||||
"symfony/translation": "<3.2",
|
"symfony/translation": "<3.2",
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
3.4.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* added `AddCacheClearerPass`
|
||||||
|
* added `AddCacheWarmerPass`
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
<?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\Component\HttpKernel\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the cache clearers.
|
||||||
|
*
|
||||||
|
* @author Dustin Dobervich <ddobervich@gmail.com>
|
||||||
|
*/
|
||||||
|
class AddCacheClearerPass implements CompilerPassInterface
|
||||||
|
{
|
||||||
|
private $cacheClearerId;
|
||||||
|
private $cacheClearerTag;
|
||||||
|
|
||||||
|
public function __construct($cacheClearerId = 'cache_clearer', $cacheClearerTag = 'kernel.cache_clearer')
|
||||||
|
{
|
||||||
|
$this->cacheClearerId = $cacheClearerId;
|
||||||
|
$this->cacheClearerTag = $cacheClearerTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function process(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
if (!$container->hasDefinition($this->cacheClearerId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$clearers = array();
|
||||||
|
foreach ($container->findTaggedServiceIds($this->cacheClearerTag, true) as $id => $attributes) {
|
||||||
|
$clearers[] = new Reference($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$container->getDefinition($this->cacheClearerId)->replaceArgument(0, $clearers);
|
||||||
|
}
|
||||||
|
}
|
@ -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\Component\HttpKernel\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the cache warmers.
|
||||||
|
*
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*/
|
||||||
|
class AddCacheWarmerPass implements CompilerPassInterface
|
||||||
|
{
|
||||||
|
use PriorityTaggedServiceTrait;
|
||||||
|
|
||||||
|
private $cacheWarmerId;
|
||||||
|
private $cacheWarmerTag;
|
||||||
|
|
||||||
|
public function __construct($cacheWarmerId = 'cache_warmer', $cacheWarmerTag = 'kernel.cache_warmer')
|
||||||
|
{
|
||||||
|
$this->cacheWarmerId = $cacheWarmerId;
|
||||||
|
$this->cacheWarmerTag = $cacheWarmerTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function process(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
if (!$container->hasDefinition($this->cacheWarmerId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$warmers = $this->findAndSortTaggedServices($this->cacheWarmerTag, $container);
|
||||||
|
|
||||||
|
if (empty($warmers)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container->getDefinition($this->cacheWarmerId)->replaceArgument(0, $warmers);
|
||||||
|
}
|
||||||
|
}
|
@ -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\Component\HttpKernel\Tests\DependencyInjection;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass;
|
||||||
|
|
||||||
|
class AddCacheClearerPassTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testThatCacheClearer()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$definition = $container->register('cache_clearer')->addArgument(null);
|
||||||
|
$container->register('my_cache_clearer_service1')->addTag('kernel.cache_clearer');
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheClearerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
new Reference('my_cache_clearer_service1'),
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $definition->getArgument(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheClearerDefinition()
|
||||||
|
{
|
||||||
|
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
|
||||||
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
|
||||||
|
|
||||||
|
$container->expects($this->never())->method('findTaggedServiceIds');
|
||||||
|
$container->expects($this->never())->method('getDefinition');
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('hasDefinition')
|
||||||
|
->with('cache_clearer')
|
||||||
|
->will($this->returnValue(false));
|
||||||
|
$definition->expects($this->never())->method('replaceArgument');
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheClearerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
<?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\Component\HttpKernel\Tests\DependencyInjection;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass;
|
||||||
|
|
||||||
|
class AddCacheWarmerPassTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testThatCacheWarmersAreProcessedInPriorityOrder()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$definition = $container->register('cache_warmer')->addArgument(null);
|
||||||
|
$container->register('my_cache_warmer_service1')->addTag('kernel.cache_warmer', array('priority' => 100));
|
||||||
|
$container->register('my_cache_warmer_service2')->addTag('kernel.cache_warmer', array('priority' => 200));
|
||||||
|
$container->register('my_cache_warmer_service3')->addTag('kernel.cache_warmer');
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
new Reference('my_cache_warmer_service2'),
|
||||||
|
new Reference('my_cache_warmer_service1'),
|
||||||
|
new Reference('my_cache_warmer_service3'),
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $definition->getArgument(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
|
||||||
|
{
|
||||||
|
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
|
||||||
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
|
||||||
|
|
||||||
|
$container->expects($this->never())->method('findTaggedServiceIds');
|
||||||
|
$container->expects($this->never())->method('getDefinition');
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('hasDefinition')
|
||||||
|
->with('cache_warmer')
|
||||||
|
->will($this->returnValue(false));
|
||||||
|
$definition->expects($this->never())->method('replaceArgument');
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testThatCacheWarmersMightBeNotDefined()
|
||||||
|
{
|
||||||
|
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
|
||||||
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
|
||||||
|
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('findTaggedServiceIds')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
$container->expects($this->never())->method('getDefinition');
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('hasDefinition')
|
||||||
|
->with('cache_warmer')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$definition->expects($this->never())->method('replaceArgument');
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user