From d49df3d09e6b0c788b5ffdd4b7b398bd7ce41c96 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Mon, 15 Dec 2025 17:24:59 +0100 Subject: [PATCH 1/2] Allow Symfony 8.x to be used --- .github/workflows/tests.yml | 1 + composer.json | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b3afa5b..c8c6396 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,6 +18,7 @@ jobs: - { php-version: 8.3, symfony-version: 6.4.*, orm-version: '^3.0', dependency-version: '' } - { php-version: 8.4, symfony-version: 7.*, orm-version: '^2.20', dependency-version: '' } - { php-version: 8.4, symfony-version: 7.*, orm-version: '^3.0', dependency-version: '' } + - { php-version: 8.4, symfony-version: 8.*, orm-version: '^3.0', dependency-version: '' } 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' }}) steps: - uses: actions/checkout@v4 diff --git a/composer.json b/composer.json index 2ff34dd..10d6ea1 100644 --- a/composer.json +++ b/composer.json @@ -21,25 +21,25 @@ "require": { "php": ">= 8.1", - "doctrine/collections": "^1.6|^2.0", - "doctrine/dbal": "^3.0|^4.0", - "doctrine/event-manager": "^1.1|^2.0", - "doctrine/orm": "^2.13|^3.0", - "doctrine/persistence": "^2.4|^3.1|^4.0", - "psr/log": "^2.0|^3.0", - "symfony/config": "^6.4|^7.0", - "symfony/dependency-injection": "^6.4|^7.0", - "symfony/deprecation-contracts": "^2.0|^3.0", - "symfony/event-dispatcher": "^6.4|^7.0", - "symfony/http-kernel": "^6.4|^7.0" + "doctrine/collections": "^1.6 || ^2.0", + "doctrine/dbal": "^3.0 || ^4.0", + "doctrine/event-manager": "^1.1 || ^2.0", + "doctrine/orm": "^2.13 || ^3.0", + "doctrine/persistence": "^2.4 || ^3.1 || ^4.0", + "psr/log": "^2.0 || ^3.0", + "symfony/config": "^6.4 || ^7.3 || ^8.0", + "symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0", + "symfony/deprecation-contracts": "^2.0 || ^3.0", + "symfony/event-dispatcher": "^6.4 || ^7.3 || ^8.0", + "symfony/http-kernel": "^6.4 || ^7.3 || ^8.0" }, "require-dev": { "doctrine/common": "^3.1", - "doctrine/doctrine-bundle": "^2.12", + "doctrine/doctrine-bundle": "^2.12 || ^3.0", "phpunit/phpunit": "^10.5.58", - "symfony/framework-bundle": "^6.4|^7.0", - "symfony/yaml": "^6.4|^7.0" + "symfony/framework-bundle": "^6.4 || ^7.3 || ^8.0", + "symfony/yaml": "^6.4 || ^7.3 || ^8.0" }, "config": { From b52462d9edcece98ecfc81a2e864bf3363de5fa8 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Mon, 15 Dec 2025 17:33:30 +0100 Subject: [PATCH 2/2] Load configuration as PHP --- tests/Fixtures/TestKernel.php | 44 +++++++++++++++++++++++++++++++- tests/Fixtures/config/config.yml | 39 ---------------------------- 2 files changed, 43 insertions(+), 40 deletions(-) delete mode 100644 tests/Fixtures/config/config.yml diff --git a/tests/Fixtures/TestKernel.php b/tests/Fixtures/TestKernel.php index 11a99a7..e3b5125 100644 --- a/tests/Fixtures/TestKernel.php +++ b/tests/Fixtures/TestKernel.php @@ -2,7 +2,11 @@ namespace Webfactory\Bundle\PolyglotBundle\Tests\Fixtures; +use Doctrine\DBAL\Logging\Middleware; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\Kernel; class TestKernel extends Kernel @@ -18,7 +22,45 @@ public function registerBundles(): iterable public function registerContainerConfiguration(LoaderInterface $loader): void { - $loader->load(__DIR__.'/config/config.yml'); + $loader->load(static function (ContainerBuilder $container): void { + // Framework configuration + $container->loadFromExtension('framework', [ + 'test' => true, + ] + (Kernel::VERSION_ID < 70000 ? ['annotations' => ['enabled' => false]] : [])); + + // Webfactory Polyglot Bundle configuration + $container->loadFromExtension('webfactory_polyglot', [ + 'defaultLocale' => 'en_GB', + ]); + + // Doctrine configuration + $container->loadFromExtension('doctrine', [ + 'dbal' => [ + 'driver' => 'pdo_sqlite', + 'memory' => true, + ], + 'orm' => [ + 'mappings' => [ + 'WebfactoryPolyglotBundle' => [ + 'type' => 'attribute', + 'dir' => '../tests/Fixtures/Entity', + 'prefix' => 'Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\Entity', + ], + ], + ], + ]); + + // Service definitions + $container->setDefinition('entity_manager_for_loading', new ChildDefinition('doctrine.orm.entity_manager')); + + $container->register(QueryLogger::class); + + $container->register(Middleware::class) + ->setArguments([ + '$logger' => new Reference(QueryLogger::class), + ]) + ->addTag('doctrine.middleware'); + }); } public function getProjectDir(): string diff --git a/tests/Fixtures/config/config.yml b/tests/Fixtures/config/config.yml deleted file mode 100644 index 87e0e8f..0000000 --- a/tests/Fixtures/config/config.yml +++ /dev/null @@ -1,39 +0,0 @@ -framework: - test: true - annotations: false - -webfactory_polyglot: - defaultLocale: en_GB - -services: - # Basically a copy of the default entity manager, so that we have a dedicated instance - # that can be used to setup the schema and import entities, without e. g. initializing - # the identity map or similar in the default EM. - entity_manager_for_loading: - parent: doctrine.orm.entity_manager - - Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\QueryLogger: ~ - Doctrine\DBAL\Logging\Middleware: - arguments: - $logger: '@Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\QueryLogger' - tags: - - doctrine.middleware - -doctrine: - dbal: - driver: pdo_sqlite - memory: true - orm: - controller_resolver: - auto_mapping: false - - # The following would silence Doctrine bundle deprecation messages, but it's not straightforward - # to do while still being compliant across a range of ORM / DoctrineBundle versions. - #report_fields_where_declared: true - #enable_lazy_ghost_objects: true - mappings: - WebfactoryPolyglotBundle: - type: attribute - dir: ../tests/Fixtures/Entity - prefix: Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\Entity -