Merge branch '3.2'

* 3.2:
  Fix tests that do not trigger any depreciation
  [HttpFoundation] Fix test ensuring isMethodSafe() checks cacheable
  [Cache] Mark FilesystemAdapterTrait as internal
  [FrameworkBundle] Dont rely on any parent definition for "cache.annotations"
This commit is contained in:
Fabien Potencier 2016-11-26 20:22:04 -08:00
commit ea7e2452bd
8 changed files with 35 additions and 12 deletions

View File

@ -25,8 +25,8 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
private $skippedFile = false;
private $wasSkipped = array();
private $isSkipped = array();
private $expectedDeprecations;
private $gatheredDeprecations;
private $expectedDeprecations = array();
private $gatheredDeprecations = array();
private $previousErrorHandler;
/**
@ -181,7 +181,8 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
$test->getTestResultObject()->addFailure($test, $e, $time);
}
$this->expectedDeprecations = $this->gatheredDeprecations = $this->previousErrorHandler = null;
$this->expectedDeprecations = $this->gatheredDeprecations = array();
$this->previousErrorHandler = null;
}
if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false));

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
@ -38,5 +39,22 @@ final class CachePoolClearerPass implements CompilerPassInterface
}
}
}
if (!$container->has('cache.annotations')) {
return;
}
$factory = array(AbstractAdapter::class, 'createSystemCache');
$annotationsPool = $container->getDefinition('cache.annotations');
if ($factory !== $annotationsPool->getFactory() || 4 !== count($annotationsPool->getArguments())) {
return;
}
if ($container->has('monolog.logger.cache')) {
$annotationsPool->addArgument(new Reference('monolog.logger.cache'));
} elseif ($container->has('cache.system')) {
$systemPool = $container->getDefinition('cache.system');
if ($factory === $systemPool->getFactory() && 5 <= count($systemArgs = $systemPool->getArguments())) {
$annotationsPool->addArgument($systemArgs[4]);
}
}
}
}

View File

@ -1238,6 +1238,7 @@ class FrameworkExtension extends Extension
private function registerCacheConfiguration(array $config, ContainerBuilder $container)
{
$version = substr(str_replace('/', '-', base64_encode(hash('sha256', uniqid(mt_rand(), true), true))), 0, 22);
$container->getDefinition('cache.annotations')->replaceArgument(2, $version);
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);

View File

@ -93,12 +93,12 @@ class FrameworkBundle extends Bundle
$container->addCompilerPass(new SerializerPass());
$container->addCompilerPass(new PropertyInfoPass());
$container->addCompilerPass(new ControllerArgumentValueResolverPass());
$container->addCompilerPass(new CachePoolPass());
$container->addCompilerPass(new CachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 32);
$container->addCompilerPass(new ValidateWorkflowsPass());
$container->addCompilerPass(new CachePoolClearerPass(), PassConfig::TYPE_AFTER_REMOVING);
if ($container->getParameter('kernel.debug')) {
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1);
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);

View File

@ -22,8 +22,13 @@
<tag name="cache.pool" />
</service>
<service id="cache.annotations" parent="cache.system" public="false">
<tag name="cache.pool" />
<service id="cache.annotations" class="Symfony\Component\Cache\Adapter\AdapterInterface" public="false">
<factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" />
<tag name="cache.pool" clearer="cache.default_clearer" />
<argument /> <!-- namespace -->
<argument>0</argument> <!-- default lifetime -->
<argument /> <!-- version -->
<argument>%kernel.cache_dir%/pools</argument>
</service>
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true">

View File

@ -15,6 +15,8 @@ use Symfony\Component\Cache\Exception\InvalidArgumentException;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
trait FilesystemAdapterTrait
{

View File

@ -28,8 +28,6 @@ abstract class AdapterTestCase extends CachePoolTest
{
if (isset($this->skippedTests[__FUNCTION__])) {
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
return;
}
$cache = $this->createCachePool(2);
@ -51,8 +49,6 @@ abstract class AdapterTestCase extends CachePoolTest
{
if (isset($this->skippedTests[__FUNCTION__])) {
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
return;
}
$cache = $this->createCachePool();

View File

@ -2020,7 +2020,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
public function testMethodSafeChecksCacheable()
{
$request = new Request();
$request->setMethod('OPTION');
$request->setMethod('OPTIONS');
$this->assertFalse($request->isMethodSafe());
}