diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 2c7bf86d..24208bdb 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -28,13 +28,15 @@ jobs: - php-version: '8.3' symfony-version: '7.*' - php-version: '8.4' - symfony-version: '7.*' + symfony-version: '8.*' + - php-version: '8.5' + symfony-version: '8.*' # Minimum supported dependencies with the oldest PHP version - php-version: '8.1' composer-flag: '--prefer-stable --prefer-lowest' symfony-version: '6.4' # Test latest unreleased versions - - php-version: '8.4' + - php-version: '8.5' stability: 'dev' name: PHP ${{ matrix.php-version }} Test on Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}} ${{ matrix.stability }} ${{ matrix.composer-flag }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9bd588..8aeab6d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Changelog 3.x === +3.3 +--- + +* Compatibility with Symfony 8 (changed configuration from XML to PHP). +* Tested with php 8.5. + 3.2.0 ----- diff --git a/composer.json b/composer.json index b69ddd0b..3d0c3bea 100644 --- a/composer.json +++ b/composer.json @@ -30,12 +30,12 @@ "require": { "php": "^8.1", "friendsofsymfony/http-cache": "^3.0", - "symfony/dependency-injection": "^6.4 || ^7.0", - "symfony/expression-language": "^6.4 || ^7.0", - "symfony/framework-bundle": "^6.4 || ^7.0", - "symfony/http-foundation": "^6.4 || ^7.0", - "symfony/http-kernel": "^6.4 || ^7.0", - "symfony/security-bundle": "^6.4 || ^7.0" + "symfony/dependency-injection": "^6.4 || ^7.0 || ^8.0", + "symfony/expression-language": "^6.4 || ^7.0 || ^8.0", + "symfony/framework-bundle": "^6.4 || ^7.0 || ^8.0", + "symfony/http-foundation": "^6.4 || ^7.0 || ^8.0", + "symfony/http-kernel": "^6.4 || ^7.0 || ^8.0", + "symfony/security-bundle": "^6.4 || ^7.0 || ^8.0" }, "require-dev": { "php-http/guzzle7-adapter": "^0.1.1", @@ -45,18 +45,18 @@ "guzzlehttp/guzzle": "^7.2", "mockery/mockery": "^1.6.9", "monolog/monolog": "*", - "symfony/browser-kit": "^6.4 || ^7.0", - "symfony/console": "^6.4 || ^7.0", - "symfony/finder": "^6.4 || ^7.0", + "symfony/browser-kit": "^6.4 || ^7.0 || ^8.0", + "symfony/console": "^6.4 || ^7.0 || ^8.0", + "symfony/finder": "^6.4 || ^7.0 || ^8.0", "phpunit/phpunit": "^10.5", - "symfony/twig-bundle": "^6.4 || ^7.0", + "symfony/twig-bundle": "^6.4 || ^7.0 || ^8.0", "twig/twig": "^v3.8", - "symfony/yaml": "^6.4 || ^7.0", - "symfony/css-selector": "^6.4 || ^7.0", - "symfony/monolog-bundle": "^3.0", - "symfony/routing": "^6.4 || ^7.0", - "matthiasnoback/symfony-config-test": "^4.3.0 || ^5.1", - "matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0", + "symfony/yaml": "^6.4 || ^7.0 || ^8.0", + "symfony/css-selector": "^6.4 || ^7.0 || ^8.0", + "symfony/monolog-bundle": "*", + "symfony/routing": "^6.4 || ^7.0 || ^8.0", + "matthiasnoback/symfony-config-test": "^5.2 || ^6.1", + "matthiasnoback/symfony-dependency-injection-test": "^5.1 || ^6.2", "phpstan/phpstan": "^2", "phpstan/phpstan-symfony": "^2", "phpstan/extension-installer": "^1.4", @@ -90,6 +90,9 @@ "allow-plugins": { "php-http/discovery": true, "phpstan/extension-installer": true + }, + "audit": { + "block-insecure": false } } } diff --git a/src/DependencyInjection/FOSHttpCacheExtension.php b/src/DependencyInjection/FOSHttpCacheExtension.php index 15e1aea3..37abc6b6 100644 --- a/src/DependencyInjection/FOSHttpCacheExtension.php +++ b/src/DependencyInjection/FOSHttpCacheExtension.php @@ -27,7 +27,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Twig\TwigFunction; @@ -44,15 +44,15 @@ public function load(array $configs, ContainerBuilder $container): void $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('matcher.xml'); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('matcher.php'); if ($config['debug']['enabled'] || (!empty($config['cache_control']))) { $debugHeader = $config['debug']['enabled'] ? $config['debug']['header'] : false; $ttlHeader = $config['cache_control']['ttl_header'] ?? CacheControlListener::DEFAULT_TTL_HEADER_NAME; $container->setParameter('fos_http_cache.debug_header', $debugHeader); $container->setParameter('fos_http_cache.ttl_header', $ttlHeader); - $loader->load('cache_control_listener.xml'); + $loader->load('cache_control_listener.php'); } $this->loadCacheable($container, $config['cacheable']); @@ -99,9 +99,9 @@ public function load(array $configs, ContainerBuilder $container): void $generateUrlType = $config['cache_manager']['generate_url_type']; } $container->setParameter('fos_http_cache.cache_manager.generate_url_type', $generateUrlType); - $loader->load('cache_manager.xml'); + $loader->load('cache_manager.php'); if (class_exists(Application::class)) { - $loader->load('cache_manager_commands.xml'); + $loader->load('cache_manager_commands.php'); } } @@ -117,7 +117,7 @@ public function load(array $configs, ContainerBuilder $container): void } if ($config['invalidation']['enabled']) { - $loader->load('invalidation_listener.xml'); + $loader->load('invalidation_listener.php'); if (!empty($config['invalidation']['expression_language'])) { $container->setAlias( @@ -139,10 +139,10 @@ public function load(array $configs, ContainerBuilder $container): void unset($config['flash_message']['enabled']); $container->setParameter('fos_http_cache.event_listener.flash_message.options', $config['flash_message']); - $loader->load('flash_message.xml'); + $loader->load('flash_message.php'); } - $loader->load('attributes.xml'); + $loader->load('attributes.php'); } private function loadCacheable(ContainerBuilder $container, array $config): void @@ -279,7 +279,7 @@ private function parseResponseMatcher(ContainerBuilder $container, array $config return new Reference('fos_http_cache.response_matcher.cacheable'); } - private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadUserContext(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $configuredUserIdentifierHeaders = array_map('strtolower', $config['user_identifier_headers']); $completeUserIdentifierHeaders = $configuredUserIdentifierHeaders; @@ -287,7 +287,7 @@ private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loa $completeUserIdentifierHeaders[] = 'cookie'; } - $loader->load('user_context.xml'); + $loader->load('user_context.php'); $container->getDefinition('fos_http_cache.user_context.request_matcher') ->replaceArgument(0, $config['match']['accept']) @@ -326,7 +326,7 @@ private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loa } } - private function loadProxyClient(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadProxyClient(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { if (isset($config['varnish'])) { $this->loadVarnish($container, $loader, $config['varnish']); @@ -347,7 +347,7 @@ private function loadProxyClient(ContainerBuilder $container, XmlFileLoader $loa $this->loadFastly($container, $loader, $config['fastly']); } if (isset($config['noop'])) { - $loader->load('noop.xml'); + $loader->load('noop.php'); } $container->setAlias( @@ -410,7 +410,7 @@ private function createHttpDispatcherDefinition(ContainerBuilder $container, arr $container->setDefinition($serviceName, $definition); } - private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadVarnish(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.varnish.http_dispatcher'); $options = [ @@ -426,7 +426,7 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader, } $container->setParameter('fos_http_cache.proxy_client.varnish.options', $options); - $loader->load('varnish.xml'); + $loader->load('varnish.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -441,13 +441,13 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader, ->replaceArgument(3, $streamFactory); } - private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadNginx(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.nginx.http_dispatcher'); $container->setParameter('fos_http_cache.proxy_client.nginx.options', [ 'purge_location' => $config['purge_location'], ]); - $loader->load('nginx.xml'); + $loader->load('nginx.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -462,7 +462,7 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a ->replaceArgument(3, $streamFactory); } - private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadSymfony(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $serviceName = 'fos_http_cache.proxy_client.symfony.http_dispatcher'; @@ -485,7 +485,7 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, } $container->setParameter('fos_http_cache.proxy_client.symfony.options', $options); - $loader->load('symfony.xml'); + $loader->load('symfony.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -500,7 +500,7 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, ->replaceArgument(3, $streamFactory); } - private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadCloudflare(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.cloudflare.http_dispatcher'); $options = [ @@ -510,7 +510,7 @@ private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $load $container->setParameter('fos_http_cache.proxy_client.cloudflare.options', $options); - $loader->load('cloudflare.xml'); + $loader->load('cloudflare.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -525,7 +525,7 @@ private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $load ->replaceArgument(3, $streamFactory); } - private function loadCloudfront(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadCloudfront(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { if (null !== $config['client']) { $container->setAlias( @@ -543,10 +543,10 @@ private function loadCloudfront(ContainerBuilder $container, XmlFileLoader $load 'distribution_id' => $config['distribution_id'], ]); - $loader->load('cloudfront.xml'); + $loader->load('cloudfront.php'); } - private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadFastly(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.fastly.http_dispatcher'); @@ -558,7 +558,7 @@ private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader, $container->setParameter('fos_http_cache.proxy_client.fastly.options', $options); - $loader->load('fastly.xml'); + $loader->load('fastly.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -578,7 +578,7 @@ private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader, * @param string $client Name of the client used with the cache manager, * "custom" when a custom client is used */ - private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $loader, array $config, string $client): void + private function loadCacheTagging(ContainerBuilder $container, PhpFileLoader $loader, array $config, string $client): void { if ('auto' === $config['enabled'] && !in_array($client, ['varnish', 'symfony', 'cloudflare', 'fastly'])) { return; @@ -591,12 +591,12 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo $container->setParameter('fos_http_cache.tag_handler.separator', $config['separator']); $container->setParameter('fos_http_cache.tag_handler.strict', $config['strict']); - $loader->load('cache_tagging.xml'); + $loader->load('cache_tagging.php'); if (class_exists(TwigFunction::class)) { - $loader->load('cache_tagging_twig.xml'); + $loader->load('cache_tagging_twig.php'); } if (class_exists(Application::class)) { - $loader->load('cache_tagging_commands.xml'); + $loader->load('cache_tagging_commands.php'); } if (!empty($config['expression_language'])) { @@ -618,7 +618,7 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo } } - private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadTest(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $container->setParameter('fos_http_cache.test.cache_header', $config['cache_header']); @@ -627,7 +627,7 @@ private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, ar } } - private function loadProxyServer(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadProxyServer(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { if (isset($config['varnish'])) { $this->loadVarnishProxyServer($container, $loader, $config['varnish']); @@ -643,9 +643,9 @@ private function loadProxyServer(ContainerBuilder $container, XmlFileLoader $loa ); } - private function loadVarnishProxyServer(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadVarnishProxyServer(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { - $loader->load('varnish_proxy.xml'); + $loader->load('varnish_proxy.php'); foreach ($config as $key => $value) { $container->setParameter( 'fos_http_cache.test.proxy_server.varnish.'.$key, @@ -654,9 +654,9 @@ private function loadVarnishProxyServer(ContainerBuilder $container, XmlFileLoad } } - private function loadNginxProxyServer(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadNginxProxyServer(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { - $loader->load('nginx_proxy.xml'); + $loader->load('nginx_proxy.php'); foreach ($config as $key => $value) { $container->setParameter( 'fos_http_cache.test.proxy_server.nginx.'.$key, diff --git a/src/Resources/config/attributes.php b/src/Resources/config/attributes.php new file mode 100644 index 00000000..49435355 --- /dev/null +++ b/src/Resources/config/attributes.php @@ -0,0 +1,12 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.event_listener.attributes', \FOS\HttpCacheBundle\EventListener\AttributesListener::class) + ->args([service('controller_resolver')]) + ->tag('kernel.event_subscriber'); +}; diff --git a/src/Resources/config/attributes.xml b/src/Resources/config/attributes.xml deleted file mode 100644 index 99c7f426..00000000 --- a/src/Resources/config/attributes.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/src/Resources/config/cache_control_listener.php b/src/Resources/config/cache_control_listener.php new file mode 100644 index 00000000..44df8917 --- /dev/null +++ b/src/Resources/config/cache_control_listener.php @@ -0,0 +1,27 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.event_listener.cache_control', \FOS\HttpCacheBundle\EventListener\CacheControlListener::class) + ->public() + ->args([ + '%fos_http_cache.debug_header%', + '%fos_http_cache.ttl_header%', + ]) + ->tag('kernel.event_subscriber'); + + $services->alias(\FOS\HttpCacheBundle\EventListener\CacheControlListener::class, 'fos_http_cache.event_listener.cache_control') + ->public(); + + $services->set('fos_http_cache.response_matcher.cache_control.cacheable_response', \FOS\HttpCacheBundle\Http\ResponseMatcher\CacheableResponseMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.response_matcher.cache_control.expression', \FOS\HttpCacheBundle\Http\ResponseMatcher\ExpressionResponseMatcher::class) + ->private() + ->abstract(); +}; diff --git a/src/Resources/config/cache_control_listener.xml b/src/Resources/config/cache_control_listener.xml deleted file mode 100644 index 3249d0a3..00000000 --- a/src/Resources/config/cache_control_listener.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - %fos_http_cache.debug_header% - %fos_http_cache.ttl_header% - - - - - - - - - - - - diff --git a/src/Resources/config/cache_manager.php b/src/Resources/config/cache_manager.php new file mode 100644 index 00000000..5f64f5dd --- /dev/null +++ b/src/Resources/config/cache_manager.php @@ -0,0 +1,24 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.cache_manager', \FOS\HttpCacheBundle\CacheManager::class) + ->public() + ->args([ + service('fos_http_cache.default_proxy_client'), + service('router'), + ]) + ->call('setEventDispatcher', [service('event_dispatcher')->ignoreOnInvalid()]) + ->call('setGenerateUrlType', ['%fos_http_cache.cache_manager.generate_url_type%']); + + $services->alias(\FOS\HttpCacheBundle\CacheManager::class, 'fos_http_cache.cache_manager') + ->public(); + + $services->set('fos_http_cache.event_listener.log', \FOS\HttpCache\EventListener\LogListener::class) + ->abstract() + ->args([service('logger')]); +}; diff --git a/src/Resources/config/cache_manager.xml b/src/Resources/config/cache_manager.xml deleted file mode 100644 index a09742db..00000000 --- a/src/Resources/config/cache_manager.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - %fos_http_cache.cache_manager.generate_url_type% - - - - - - - - - - diff --git a/src/Resources/config/cache_manager_commands.php b/src/Resources/config/cache_manager_commands.php new file mode 100644 index 00000000..5a85bb07 --- /dev/null +++ b/src/Resources/config/cache_manager_commands.php @@ -0,0 +1,24 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.command.invalidate_path', \FOS\HttpCacheBundle\Command\InvalidatePathCommand::class) + ->args([service('fos_http_cache.cache_manager')]) + ->tag('console.command'); + + $services->set('fos_http_cache.command.invalidate_regex', \FOS\HttpCacheBundle\Command\InvalidateRegexCommand::class) + ->args([service('fos_http_cache.cache_manager')]) + ->tag('console.command'); + + $services->set('fos_http_cache.command.refresh_path', \FOS\HttpCacheBundle\Command\RefreshPathCommand::class) + ->args([service('fos_http_cache.cache_manager')]) + ->tag('console.command'); + + $services->set('fos_http_cache.command.clear', \FOS\HttpCacheBundle\Command\ClearCommand::class) + ->args([service('fos_http_cache.cache_manager')]) + ->tag('console.command'); +}; diff --git a/src/Resources/config/cache_manager_commands.xml b/src/Resources/config/cache_manager_commands.xml deleted file mode 100644 index 297f45ab..00000000 --- a/src/Resources/config/cache_manager_commands.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/cache_tagging.php b/src/Resources/config/cache_tagging.php new file mode 100644 index 00000000..f0da077d --- /dev/null +++ b/src/Resources/config/cache_tagging.php @@ -0,0 +1,35 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.tag_handler.header_formatter', \FOS\HttpCache\TagHeaderFormatter\CommaSeparatedTagHeaderFormatter::class) + ->private() + ->args([ + '%fos_http_cache.tag_handler.response_header%', + '%fos_http_cache.tag_handler.separator%', + ]); + + $services->set('fos_http_cache.http.symfony_response_tagger', \FOS\HttpCacheBundle\Http\SymfonyResponseTagger::class) + ->public() + ->args([['header_formatter' => service('fos_http_cache.tag_handler.header_formatter'), 'strict' => '%fos_http_cache.tag_handler.strict%']]); + + $services->alias(\FOS\HttpCacheBundle\Http\SymfonyResponseTagger::class, 'fos_http_cache.http.symfony_response_tagger') + ->public(); + + $services->alias(\FOS\HttpCache\ResponseTagger::class, 'fos_http_cache.http.symfony_response_tagger') + ->public(); + + $services->set('fos_http_cache.event_listener.tag', \FOS\HttpCacheBundle\EventListener\TagListener::class) + ->args([ + service('fos_http_cache.cache_manager'), + service('fos_http_cache.http.symfony_response_tagger'), + service('fos_http_cache.rule_matcher.cacheable'), + service('fos_http_cache.rule_matcher.must_invalidate'), + service('fos_http_cache.tag_handler.expression_language')->ignoreOnInvalid(), + ]) + ->tag('kernel.event_subscriber'); +}; diff --git a/src/Resources/config/cache_tagging.xml b/src/Resources/config/cache_tagging.xml deleted file mode 100644 index b23abb88..00000000 --- a/src/Resources/config/cache_tagging.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %fos_http_cache.tag_handler.response_header% - %fos_http_cache.tag_handler.separator% - - - - - - %fos_http_cache.tag_handler.strict% - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/cache_tagging_commands.php b/src/Resources/config/cache_tagging_commands.php new file mode 100644 index 00000000..70b34408 --- /dev/null +++ b/src/Resources/config/cache_tagging_commands.php @@ -0,0 +1,12 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.command.invalidate_tag', \FOS\HttpCacheBundle\Command\InvalidateTagCommand::class) + ->args([service('fos_http_cache.cache_manager')]) + ->tag('console.command', ['command' => 'fos:httpcache:invalidate:tag']); +}; diff --git a/src/Resources/config/cache_tagging_commands.xml b/src/Resources/config/cache_tagging_commands.xml deleted file mode 100644 index 1b449e17..00000000 --- a/src/Resources/config/cache_tagging_commands.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/src/Resources/config/cache_tagging_twig.php b/src/Resources/config/cache_tagging_twig.php new file mode 100644 index 00000000..c72258e6 --- /dev/null +++ b/src/Resources/config/cache_tagging_twig.php @@ -0,0 +1,12 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.twig.tag_extension', \FOS\HttpCacheBundle\Twig\CacheTagExtension::class) + ->args([service('fos_http_cache.http.symfony_response_tagger')]) + ->tag('twig.extension'); +}; diff --git a/src/Resources/config/cache_tagging_twig.xml b/src/Resources/config/cache_tagging_twig.xml deleted file mode 100644 index 192c85a5..00000000 --- a/src/Resources/config/cache_tagging_twig.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/src/Resources/config/cloudflare.php b/src/Resources/config/cloudflare.php new file mode 100644 index 00000000..21462a9b --- /dev/null +++ b/src/Resources/config/cloudflare.php @@ -0,0 +1,18 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.proxy_client.cloudflare', \FOS\HttpCache\ProxyClient\Cloudflare::class) + ->public() + ->lazy() + ->args([ + service('fos_http_cache.proxy_client.cloudflare.http_dispatcher'), + '%fos_http_cache.proxy_client.cloudflare.options%', + '', + '', + ]); +}; diff --git a/src/Resources/config/cloudflare.xml b/src/Resources/config/cloudflare.xml deleted file mode 100644 index 5e92d5a6..00000000 --- a/src/Resources/config/cloudflare.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.cloudflare.options% - - - - - - diff --git a/src/Resources/config/cloudfront.php b/src/Resources/config/cloudfront.php new file mode 100644 index 00000000..2cb535a7 --- /dev/null +++ b/src/Resources/config/cloudfront.php @@ -0,0 +1,15 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.proxy_client.cloudfront', \JeanBeru\HttpCacheCloudFront\Proxy\CloudFront::class) + ->public() + ->args([ + service('fos_http_cache.proxy_client.cloudfront.cloudfront_client'), + '%fos_http_cache.proxy_client.cloudfront.options%', + ]); +}; diff --git a/src/Resources/config/cloudfront.xml b/src/Resources/config/cloudfront.xml deleted file mode 100644 index 2f827756..00000000 --- a/src/Resources/config/cloudfront.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.cloudfront.options% - - - - diff --git a/src/Resources/config/fastly.php b/src/Resources/config/fastly.php new file mode 100644 index 00000000..0319fd7b --- /dev/null +++ b/src/Resources/config/fastly.php @@ -0,0 +1,18 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.proxy_client.fastly', \FOS\HttpCache\ProxyClient\Fastly::class) + ->private() + ->lazy() + ->args([ + service('fos_http_cache.proxy_client.fastly.http_dispatcher'), + '%fos_http_cache.proxy_client.fastly.options%', + '', + '', + ]); +}; diff --git a/src/Resources/config/fastly.xml b/src/Resources/config/fastly.xml deleted file mode 100755 index 41277e2f..00000000 --- a/src/Resources/config/fastly.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.fastly.options% - - - - - - diff --git a/src/Resources/config/flash_message.php b/src/Resources/config/flash_message.php new file mode 100644 index 00000000..273caedd --- /dev/null +++ b/src/Resources/config/flash_message.php @@ -0,0 +1,12 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.event_listener.flash_message', \FOS\HttpCacheBundle\EventListener\FlashMessageListener::class) + ->args(['%fos_http_cache.event_listener.flash_message.options%']) + ->tag('kernel.event_subscriber'); +}; diff --git a/src/Resources/config/flash_message.xml b/src/Resources/config/flash_message.xml deleted file mode 100644 index 0f4dc85a..00000000 --- a/src/Resources/config/flash_message.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - %fos_http_cache.event_listener.flash_message.options% - - - - diff --git a/src/Resources/config/invalidation_listener.php b/src/Resources/config/invalidation_listener.php new file mode 100644 index 00000000..c84bb562 --- /dev/null +++ b/src/Resources/config/invalidation_listener.php @@ -0,0 +1,17 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.event_listener.invalidation', \FOS\HttpCacheBundle\EventListener\InvalidationListener::class) + ->args([ + service('fos_http_cache.cache_manager'), + service('router'), + service('fos_http_cache.rule_matcher.must_invalidate'), + service('fos_http_cache.invalidation.expression_language')->ignoreOnInvalid(), + ]) + ->tag('kernel.event_subscriber'); +}; diff --git a/src/Resources/config/invalidation_listener.xml b/src/Resources/config/invalidation_listener.xml deleted file mode 100644 index 7576bdd8..00000000 --- a/src/Resources/config/invalidation_listener.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/Resources/config/matcher.php b/src/Resources/config/matcher.php new file mode 100644 index 00000000..67f6b1a2 --- /dev/null +++ b/src/Resources/config/matcher.php @@ -0,0 +1,71 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.request_matcher', \Symfony\Component\HttpFoundation\ChainRequestMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.request_matcher.path', \Symfony\Component\HttpFoundation\RequestMatcher\PathRequestMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.request_matcher.host', \Symfony\Component\HttpFoundation\RequestMatcher\HostRequestMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.request_matcher.methods', \Symfony\Component\HttpFoundation\RequestMatcher\MethodRequestMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.request_matcher.ips', \Symfony\Component\HttpFoundation\RequestMatcher\IpsRequestMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.request_matcher.attributes', \Symfony\Component\HttpFoundation\RequestMatcher\AttributesRequestMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.request_matcher.query_string', \FOS\HttpCacheBundle\Http\RequestMatcher\QueryStringRequestMatcher::class) + ->private() + ->abstract(); + + $services->set('fos_http_cache.rule_matcher', \FOS\HttpCacheBundle\Http\RuleMatcher::class) + ->private() + ->abstract() + ->args([ + '', + '', + ]); + + $services->set('fos_http_cache.rule_matcher.cacheable', \FOS\HttpCacheBundle\Http\RuleMatcher::class) + ->private() + ->args([ + service('fos_http_cache.request_matcher.cacheable'), + service('fos_http_cache.response_matcher.cacheable'), + ]); + + $services->set('fos_http_cache.rule_matcher.must_invalidate', \FOS\HttpCacheBundle\Http\RuleMatcher::class) + ->private() + ->args([ + service('fos_http_cache.request_matcher.unsafe'), + service('fos_http_cache.response_matcher.non_error'), + ]); + + $services->set('fos_http_cache.request_matcher.cacheable', \FOS\HttpCacheBundle\Http\RequestMatcher\CacheableRequestMatcher::class) + ->private(); + + $services->set('fos_http_cache.request_matcher.unsafe', \FOS\HttpCacheBundle\Http\RequestMatcher\UnsafeRequestMatcher::class) + ->private(); + + $services->set('fos_http_cache.response_matcher.cacheable', \FOS\HttpCacheBundle\Http\ResponseMatcher\CacheableResponseMatcher::class) + ->private() + ->args(['%fos_http_cache.cacheable.response.additional_status%']); + + $services->set('fos_http_cache.response_matcher.non_error', \FOS\HttpCacheBundle\Http\ResponseMatcher\NonErrorResponseMatcher::class) + ->private(); +}; diff --git a/src/Resources/config/matcher.xml b/src/Resources/config/matcher.xml deleted file mode 100644 index 7451a423..00000000 --- a/src/Resources/config/matcher.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %fos_http_cache.cacheable.response.additional_status% - - - - - diff --git a/src/Resources/config/nginx.php b/src/Resources/config/nginx.php new file mode 100644 index 00000000..17e8e35d --- /dev/null +++ b/src/Resources/config/nginx.php @@ -0,0 +1,17 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.proxy_client.nginx', \FOS\HttpCache\ProxyClient\Nginx::class) + ->public() + ->args([ + service('fos_http_cache.proxy_client.nginx.http_dispatcher'), + '%fos_http_cache.proxy_client.nginx.options%', + '', + '', + ]); +}; diff --git a/src/Resources/config/nginx.xml b/src/Resources/config/nginx.xml deleted file mode 100644 index f9421820..00000000 --- a/src/Resources/config/nginx.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.nginx.options% - - - - - - diff --git a/src/Resources/config/nginx_proxy.php b/src/Resources/config/nginx_proxy.php new file mode 100644 index 00000000..e2417123 --- /dev/null +++ b/src/Resources/config/nginx_proxy.php @@ -0,0 +1,14 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.test.proxy_server.nginx', \FOS\HttpCache\Test\Proxy\NginxProxy::class) + ->args(['%fos_http_cache.test.proxy_server.nginx.config_file%']) + ->call('setBinary', ['%fos_http_cache.test.proxy_server.nginx.binary%']) + ->call('setPort', ['%fos_http_cache.test.proxy_server.nginx.port%']) + ->call('setIp', ['%fos_http_cache.test.proxy_server.nginx.ip%']); +}; diff --git a/src/Resources/config/nginx_proxy.xml b/src/Resources/config/nginx_proxy.xml deleted file mode 100644 index dcbb4de8..00000000 --- a/src/Resources/config/nginx_proxy.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - %fos_http_cache.test.proxy_server.nginx.config_file% - - %fos_http_cache.test.proxy_server.nginx.binary% - - - %fos_http_cache.test.proxy_server.nginx.port% - - - %fos_http_cache.test.proxy_server.nginx.ip% - - - - - diff --git a/src/Resources/config/noop.php b/src/Resources/config/noop.php new file mode 100644 index 00000000..7a511752 --- /dev/null +++ b/src/Resources/config/noop.php @@ -0,0 +1,11 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.proxy_client.noop', \FOS\HttpCache\ProxyClient\Noop::class) + ->public(); +}; diff --git a/src/Resources/config/noop.xml b/src/Resources/config/noop.xml deleted file mode 100644 index 379c865b..00000000 --- a/src/Resources/config/noop.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/src/Resources/config/symfony.php b/src/Resources/config/symfony.php new file mode 100644 index 00000000..0720e79c --- /dev/null +++ b/src/Resources/config/symfony.php @@ -0,0 +1,17 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.proxy_client.symfony', \FOS\HttpCache\ProxyClient\Symfony::class) + ->public() + ->args([ + service('fos_http_cache.proxy_client.symfony.http_dispatcher'), + '%fos_http_cache.proxy_client.symfony.options%', + '', + '', + ]); +}; diff --git a/src/Resources/config/symfony.xml b/src/Resources/config/symfony.xml deleted file mode 100644 index fcf2e334..00000000 --- a/src/Resources/config/symfony.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.symfony.options% - - - - - - diff --git a/src/Resources/config/user_context.php b/src/Resources/config/user_context.php new file mode 100644 index 00000000..39f6a96d --- /dev/null +++ b/src/Resources/config/user_context.php @@ -0,0 +1,46 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.user_context.hash_generator', \FOS\HttpCache\UserContext\DefaultHashGenerator::class); + + $services->set('fos_http_cache.user_context.request_matcher', \FOS\HttpCacheBundle\UserContext\RequestMatcher::class) + ->args([ + '', + '', + ]); + + $services->set('fos_http_cache.event_listener.user_context', \FOS\HttpCacheBundle\EventListener\UserContextListener::class) + ->args([ + service('fos_http_cache.user_context.request_matcher'), + service('fos_http_cache.user_context.hash_generator'), + service('fos_http_cache.user_context.anonymous_request_matcher'), + service('fos_http_cache.http.symfony_response_tagger')->ignoreOnInvalid(), + '%fos_http_cache.event_listener.user_context.options%', + true, + ]) + ->tag('kernel.event_subscriber'); + + $services->set('fos_http_cache.user_context.role_provider', \FOS\HttpCacheBundle\UserContext\RoleProvider::class) + ->abstract() + ->args([service('security.token_storage')->ignoreOnInvalid()]); + + $services->set('fos_http_cache.user_context_invalidator', \FOS\HttpCacheBundle\UserContextInvalidator::class) + ->args([service('fos_http_cache.default_proxy_client')]); + + $services->set('fos_http_cache.user_context.session_logout_handler', \FOS\HttpCacheBundle\Security\Http\Logout\ContextInvalidationSessionLogoutHandler::class) + ->private() + ->args([service('fos_http_cache.user_context_invalidator')]); + + $services->set('fos_http_cache.user_context.switch_user_listener', \FOS\HttpCacheBundle\EventListener\SwitchUserListener::class) + ->private() + ->args([service('fos_http_cache.user_context_invalidator')]) + ->tag('kernel.event_subscriber'); + + $services->set('fos_http_cache.user_context.anonymous_request_matcher', \FOS\HttpCache\UserContext\AnonymousRequestMatcher::class) + ->args([[]]); +}; diff --git a/src/Resources/config/user_context.xml b/src/Resources/config/user_context.xml deleted file mode 100644 index 11954d72..00000000 --- a/src/Resources/config/user_context.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - %fos_http_cache.event_listener.user_context.options% - true - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/varnish.php b/src/Resources/config/varnish.php new file mode 100644 index 00000000..629cdb5d --- /dev/null +++ b/src/Resources/config/varnish.php @@ -0,0 +1,17 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.proxy_client.varnish', \FOS\HttpCache\ProxyClient\Varnish::class) + ->public() + ->args([ + service('fos_http_cache.proxy_client.varnish.http_dispatcher'), + '%fos_http_cache.proxy_client.varnish.options%', + '', + '', + ]); +}; diff --git a/src/Resources/config/varnish.xml b/src/Resources/config/varnish.xml deleted file mode 100644 index 57216740..00000000 --- a/src/Resources/config/varnish.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.varnish.options% - - - - - - diff --git a/src/Resources/config/varnish_proxy.php b/src/Resources/config/varnish_proxy.php new file mode 100644 index 00000000..407903f3 --- /dev/null +++ b/src/Resources/config/varnish_proxy.php @@ -0,0 +1,14 @@ +services(); + $parameters = $container->parameters(); + + $services->set('fos_http_cache.test.proxy_server.varnish', \FOS\HttpCache\Test\Proxy\VarnishProxy::class) + ->args(['%fos_http_cache.test.proxy_server.varnish.config_file%']) + ->call('setBinary', ['%fos_http_cache.test.proxy_server.varnish.binary%']) + ->call('setPort', ['%fos_http_cache.test.proxy_server.varnish.port%']) + ->call('setIp', ['%fos_http_cache.test.proxy_server.varnish.ip%']); +}; diff --git a/src/Resources/config/varnish_proxy.xml b/src/Resources/config/varnish_proxy.xml deleted file mode 100644 index 508fadaa..00000000 --- a/src/Resources/config/varnish_proxy.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - %fos_http_cache.test.proxy_server.varnish.config_file% - - %fos_http_cache.test.proxy_server.varnish.binary% - - - %fos_http_cache.test.proxy_server.varnish.port% - - - %fos_http_cache.test.proxy_server.varnish.ip% - - - - - diff --git a/tests/Unit/Command/BaseInvalidateCommandTest.php b/tests/Unit/Command/BaseInvalidateCommandTest.php index 273c722c..a2551f80 100644 --- a/tests/Unit/Command/BaseInvalidateCommandTest.php +++ b/tests/Unit/Command/BaseInvalidateCommandTest.php @@ -35,8 +35,9 @@ public function testContainerAccess(): void ; $application = new Application(); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; $command = new InvalidatePathCommand($invalidator); - $application->add($command); + $application->$addMethod($command); $command = $application->find('fos:httpcache:invalidate:path'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/ClearCommandTest.php b/tests/Unit/Command/ClearCommandTest.php index 7da0e2bf..58223dbf 100644 --- a/tests/Unit/Command/ClearCommandTest.php +++ b/tests/Unit/Command/ClearCommandTest.php @@ -32,7 +32,8 @@ public function testExecuteClear(): void ; $application = new Application(); - $application->add(new ClearCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new ClearCommand($invalidator)); $command = $application->find('fos:httpcache:clear'); $commandTester = new CommandTester($command); @@ -54,7 +55,8 @@ public function testExecuteInvalidate(): void ; $application = new Application(); - $application->add(new ClearCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new ClearCommand($invalidator)); $command = $application->find('fos:httpcache:clear'); $commandTester = new CommandTester($command); @@ -75,7 +77,8 @@ public function testExecuteNotSupported(): void ; $application = new Application(); - $application->add(new ClearCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new ClearCommand($invalidator)); $command = $application->find('fos:httpcache:clear'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/InvalidatePathCommandTest.php b/tests/Unit/Command/InvalidatePathCommandTest.php index 99b37d41..980da134 100644 --- a/tests/Unit/Command/InvalidatePathCommandTest.php +++ b/tests/Unit/Command/InvalidatePathCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new InvalidatePathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidatePathCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:path'); $commandTester = new CommandTester($command); @@ -45,7 +46,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new InvalidatePathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidatePathCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:path'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/InvalidateRegexCommandTest.php b/tests/Unit/Command/InvalidateRegexCommandTest.php index 6a78b454..3f83779c 100644 --- a/tests/Unit/Command/InvalidateRegexCommandTest.php +++ b/tests/Unit/Command/InvalidateRegexCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteNoParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new InvalidateRegexCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateRegexCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:regex'); $commandTester = new CommandTester($command); @@ -44,7 +45,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new InvalidateRegexCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateRegexCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:regex'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/InvalidateTagCommandTest.php b/tests/Unit/Command/InvalidateTagCommandTest.php index 97478147..bf6c2a8f 100644 --- a/tests/Unit/Command/InvalidateTagCommandTest.php +++ b/tests/Unit/Command/InvalidateTagCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new InvalidateTagCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateTagCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:tag'); $commandTester = new CommandTester($command); @@ -44,7 +45,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new InvalidateTagCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateTagCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:tag'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/RefreshPathCommandTest.php b/tests/Unit/Command/RefreshPathCommandTest.php index 05595284..3302053f 100644 --- a/tests/Unit/Command/RefreshPathCommandTest.php +++ b/tests/Unit/Command/RefreshPathCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new RefreshPathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new RefreshPathCommand($invalidator)); $command = $application->find('fos:httpcache:refresh:path'); $commandTester = new CommandTester($command); @@ -45,7 +46,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new RefreshPathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new RefreshPathCommand($invalidator)); $command = $application->find('fos:httpcache:refresh:path'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 3a867380..7ed2284d 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -20,6 +20,7 @@ use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; +use Symfony\Component\HttpKernel\Kernel; class ConfigurationTest extends AbstractExtensionConfigurationTestCase { @@ -41,10 +42,13 @@ public function testEmptyConfiguration(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/empty.yml', - 'config/empty.xml', 'config/empty.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/empty.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -199,10 +203,13 @@ public function testSupportsAllConfigFormats(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/full.yml', - 'config/full.xml', 'config/full.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/full.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -224,10 +231,13 @@ public function testCustomProxyClient(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/custom-client.yml', - 'config/custom-client.xml', 'config/custom-client.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/custom-client.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -258,10 +268,13 @@ public function testSupportsNginx(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/nginx.yml', - 'config/nginx.xml', 'config/nginx.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/nginx.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -296,10 +309,13 @@ public function testSupportsSymfony(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/symfony.yml', - 'config/symfony.xml', 'config/symfony.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/symfony.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -325,10 +341,13 @@ public function testSupportsCloudflare(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cloudflare.yml', - 'config/cloudflare.xml', 'config/cloudflare.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cloudflare.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -357,10 +376,13 @@ public function testSupportsCloudfront(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cloudfront.yml', - 'config/cloudfront.xml', 'config/cloudfront.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cloudfront.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -410,10 +432,13 @@ public function testSupportsFastly(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/fastly.yml', - 'config/fastly.xml', 'config/fastly.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/fastly.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -468,10 +493,13 @@ public function testSupportsNoop(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/noop.yml', - 'config/noop.xml', 'config/noop.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/noop.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -539,10 +567,13 @@ public function testSplitOptions(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/split.yml', - 'config/split.xml', 'config/split.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/split.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -558,10 +589,13 @@ public function testSupportsCacheableResponseExpression(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cacheable_response_expression.yml', - 'config/cacheable_response_expression.xml', 'config/cacheable_response_expression.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cacheable_response_expression.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -573,10 +607,13 @@ public function testCacheManagerNoClient(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cachemanager_noclient.yml', - 'config/cachemanager_noclient.xml', 'config/cachemanager_noclient.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cachemanager_noclient.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -593,10 +630,13 @@ public function testTagsNoCacheManager(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/tags_nocachemanager.yml', - 'config/tags_nocachemanager.xml', 'config/tags_nocachemanager.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/tags_nocachemanager.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -616,10 +656,13 @@ public function testTagsStrict(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/tags_strict.yml', - 'config/tags_strict.xml', 'config/tags_strict.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/tags_strict.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -659,10 +702,13 @@ public function testWeakETags(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/etag_weak.yml', - 'config/etag_weak.xml', 'config/etag_weak.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/etag_weak.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -702,10 +748,13 @@ public function testStrongETags(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/etag_true.yml', - 'config/etag_true.xml', 'config/etag_true.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/etag_true.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -717,10 +766,13 @@ public function testInvalidationNoCacheManager(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/invalidation_nocachemanager.yml', - 'config/invalidation_nocachemanager.xml', 'config/invalidation_nocachemanager.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/invalidation_nocachemanager.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -785,10 +837,13 @@ public function testInvalidDate(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/invalid_date.yml', - 'config/invalid_date.xml', 'config/invalid_date.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/invalid_date.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -825,10 +880,13 @@ public function testSupportsServersFromJsonEnv(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/servers_from_jsonenv.yml', - 'config/servers_from_jsonenv.xml', 'config/servers_from_jsonenv.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/servers_from_jsonenv.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -860,10 +918,13 @@ public function testConfigureExpressionLanguageService(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/servers_from_jsonenv.yml', - 'config/servers_from_jsonenv.xml', 'config/servers_from_jsonenv.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/servers_from_jsonenv.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); }