Skip to content

Commit 0b71665

Browse files
authored
Bump requirements to currently supported Symfony versions, allow 8.x to be used (#88)
In order to get a test Kernel with a configuration that is compatible across Symfony 6.4 to 8.0, we need to switch to PHP as the configuration mechanism so that we can conditionally include the `framework.annotations` configuration setting. (Case 204755)
1 parent 4ba86a5 commit 0b71665

File tree

4 files changed

+58
-54
lines changed

4 files changed

+58
-54
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- { php-version: 8.3, symfony-version: 6.4.*, orm-version: '^3.0', dependency-version: '' }
1919
- { php-version: 8.4, symfony-version: 7.*, orm-version: '^2.20', dependency-version: '' }
2020
- { php-version: 8.4, symfony-version: 7.*, orm-version: '^3.0', dependency-version: '' }
21+
- { php-version: 8.4, symfony-version: 8.*, orm-version: '^3.0', dependency-version: '' }
2122
name: PHPUnit (PHP ${{matrix.php-version}}, Symfony version constraint ${{ matrix.symfony-version || 'none' }}, Doctrine ORM version constraint ${{ matrix.orm-version || 'none' }}, ${{ matrix.dependency-version || 'prefer-stable' }})
2223
steps:
2324
- uses: actions/checkout@v4

composer.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@
2121

2222
"require": {
2323
"php": ">= 8.1",
24-
"doctrine/collections": "^1.6|^2.0",
25-
"doctrine/dbal": "^3.0|^4.0",
26-
"doctrine/event-manager": "^1.1|^2.0",
27-
"doctrine/orm": "^2.13|^3.0",
28-
"doctrine/persistence": "^2.4|^3.1|^4.0",
29-
"psr/log": "^2.0|^3.0",
30-
"symfony/config": "^6.4|^7.0",
31-
"symfony/dependency-injection": "^6.4|^7.0",
32-
"symfony/deprecation-contracts": "^2.0|^3.0",
33-
"symfony/event-dispatcher": "^6.4|^7.0",
34-
"symfony/http-kernel": "^6.4|^7.0"
24+
"doctrine/collections": "^1.6 || ^2.0",
25+
"doctrine/dbal": "^3.0 || ^4.0",
26+
"doctrine/event-manager": "^1.1 || ^2.0",
27+
"doctrine/orm": "^2.13 || ^3.0",
28+
"doctrine/persistence": "^2.4 || ^3.1 || ^4.0",
29+
"psr/log": "^2.0 || ^3.0",
30+
"symfony/config": "^6.4 || ^7.3 || ^8.0",
31+
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
32+
"symfony/deprecation-contracts": "^2.0 || ^3.0",
33+
"symfony/event-dispatcher": "^6.4 || ^7.3 || ^8.0",
34+
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0"
3535
},
3636

3737
"require-dev": {
3838
"doctrine/common": "^3.1",
39-
"doctrine/doctrine-bundle": "^2.12",
39+
"doctrine/doctrine-bundle": "^2.12 || ^3.0",
4040
"phpunit/phpunit": "^10.5.58",
41-
"symfony/framework-bundle": "^6.4|^7.0",
42-
"symfony/yaml": "^6.4|^7.0"
41+
"symfony/framework-bundle": "^6.4 || ^7.3 || ^8.0",
42+
"symfony/yaml": "^6.4 || ^7.3 || ^8.0"
4343
},
4444

4545
"config": {

tests/Fixtures/TestKernel.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
namespace Webfactory\Bundle\PolyglotBundle\Tests\Fixtures;
44

5+
use Doctrine\DBAL\Logging\Middleware;
56
use Symfony\Component\Config\Loader\LoaderInterface;
7+
use Symfony\Component\DependencyInjection\ChildDefinition;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
use Symfony\Component\DependencyInjection\Reference;
610
use Symfony\Component\HttpKernel\Kernel;
711

812
class TestKernel extends Kernel
@@ -18,7 +22,45 @@ public function registerBundles(): iterable
1822

1923
public function registerContainerConfiguration(LoaderInterface $loader): void
2024
{
21-
$loader->load(__DIR__.'/config/config.yml');
25+
$loader->load(static function (ContainerBuilder $container): void {
26+
// Framework configuration
27+
$container->loadFromExtension('framework', [
28+
'test' => true,
29+
] + (Kernel::VERSION_ID < 70000 ? ['annotations' => ['enabled' => false]] : []));
30+
31+
// Webfactory Polyglot Bundle configuration
32+
$container->loadFromExtension('webfactory_polyglot', [
33+
'defaultLocale' => 'en_GB',
34+
]);
35+
36+
// Doctrine configuration
37+
$container->loadFromExtension('doctrine', [
38+
'dbal' => [
39+
'driver' => 'pdo_sqlite',
40+
'memory' => true,
41+
],
42+
'orm' => [
43+
'mappings' => [
44+
'WebfactoryPolyglotBundle' => [
45+
'type' => 'attribute',
46+
'dir' => '../tests/Fixtures/Entity',
47+
'prefix' => 'Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\Entity',
48+
],
49+
],
50+
],
51+
]);
52+
53+
// Service definitions
54+
$container->setDefinition('entity_manager_for_loading', new ChildDefinition('doctrine.orm.entity_manager'));
55+
56+
$container->register(QueryLogger::class);
57+
58+
$container->register(Middleware::class)
59+
->setArguments([
60+
'$logger' => new Reference(QueryLogger::class),
61+
])
62+
->addTag('doctrine.middleware');
63+
});
2264
}
2365

2466
public function getProjectDir(): string

tests/Fixtures/config/config.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)