diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4557343..b3f36f6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,6 +32,7 @@ jobs: matrix: php-version: ['7.4', '8.1', '8.2', '8.3', '8.4'] sf-version: ['5.4', '6.4', '7.0', '7.1', '7.2', '7.3'] + dependencies: ['locked'] exclude: - php-version: '7.4' sf-version: '6.4' @@ -39,6 +40,8 @@ jobs: sf-version: '7.0' - php-version: '7.4' sf-version: '7.1' + - php-version: '7.4' + sf-version: '7.2' - php-version: '7.4' sf-version: '7.3' - php-version: '8.1' @@ -47,6 +50,8 @@ jobs: sf-version: '7.0' - php-version: '8.1' sf-version: '7.1' + - php-version: '8.1' + sf-version: '7.2' - php-version: '8.1' sf-version: '7.3' - php-version: '8.2' @@ -55,14 +60,23 @@ jobs: sf-version: '5.4' - php-version: '8.4' sf-version: '5.4' - - php-version: '7.4' - sf-version: '7.2' - php-version: '8.0' sf-version: '7.2' - - php-version: '8.1' - sf-version: '7.2' + include: + - php-version: '7.4' + sf-version: '5.4' + dependencies: 'lowest' + - php-version: '7.4' + sf-version: '5.4' + dependencies: 'highest' + - php-version: '8.4' + sf-version: '7.3' + dependencies: 'lowest' + - php-version: '8.4' + sf-version: '7.3' + dependencies: 'highest' - name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*) + name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)${{ matrix.dependencies != 'locked' && format(' ({0})', matrix.dependencies) || '' }} steps: - name: Checkout code uses: actions/checkout@v5 @@ -85,15 +99,17 @@ jobs: env: SYMFONY_REQUIRE: ${{ matrix.sf-version }}.* with: - dependency-versions: 'highest' + composer-options: --no-interaction --no-progress --prefer-dist --dev + dependency-versions: "${{ matrix.dependencies }}" - name: Run test suite + working-directory: ${{ github.workspace }} run: composer test:unit -- --coverage-clover coverage.xml - name: Upload coverage file uses: actions/upload-artifact@v4 with: - name: 'phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}-coverage' + name: "phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}-${{ matrix.dependencies }}-coverage" path: 'coverage.xml' code-style: diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index de29a33..adef17b 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,7 +13,7 @@ ->setFinder($finder) ->setRules([ '@Symfony' => true, - '@PHP80Migration:risky' => true, + '@PHP8x0Migration:risky' => true, 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], 'global_namespace_import' => [ 'import_classes' => false, diff --git a/composer.json b/composer.json index 47c0465..0e5d9b5 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require": { "php": "^7.4|^8.0", "ext-json": "*", - "doctrine/doctrine-bundle": "^2.10", + "doctrine/doctrine-bundle": "^2.10 || ^3.0", "meilisearch/meilisearch-php": "^1.0.0", "symfony/config": "^5.4 || ^6.0 || ^7.0", "symfony/dependency-injection": "^5.4.17 || ^6.0 || ^7.0", diff --git a/tests/Kernel.php b/tests/Kernel.php index 28b7242..da87012 100644 --- a/tests/Kernel.php +++ b/tests/Kernel.php @@ -5,8 +5,8 @@ namespace Meilisearch\Bundle\Tests; use Doctrine\Bundle\DoctrineBundle\ConnectionFactory; +use Doctrine\Bundle\DoctrineBundle\Dbal\BlacklistSchemaAssetFilter; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; -use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\LegacyReflectionFields; use Meilisearch\Bundle\MeilisearchBundle; use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver; @@ -29,18 +29,30 @@ public function registerBundles(): iterable protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { + $loader->load(__DIR__.'/config/framework.yaml'); + + $doctrineBundleV3 = !class_exists(BlacklistSchemaAssetFilter::class); + if (PHP_VERSION_ID >= 80000) { - if (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) { - $loader->load(__DIR__.'/config/config.yaml'); + if ($doctrineBundleV3) { + $loader->load(__DIR__.'/config/doctrine.yaml'); + } elseif (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) { + $loader->load(__DIR__.'/config/doctrine_v2.yaml'); } else { - $loader->load(__DIR__.'/config/config_old_proxy.yaml'); + $loader->load(__DIR__.'/config/doctrine_old_proxy.yaml'); } } else { - $loader->load(__DIR__.'/config/config_php7.yaml'); + $container->prependExtensionConfig('framework', [ + 'annotations' => true, + 'serializer' => ['enable_annotations' => true], + 'router' => ['utf8' => true], + ]); + + $loader->load(__DIR__.'/config/doctrine_php7.yaml'); } $loader->load(__DIR__.'/config/meilisearch.yaml'); - if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) { + if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP') && !$doctrineBundleV3) { $container->prependExtensionConfig('doctrine', [ 'orm' => [ 'report_fields_where_declared' => true, @@ -49,15 +61,6 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa ]); } - // @phpstan-ignore-next-line - if (method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && Kernel::VERSION_ID >= 60100) { - $container->prependExtensionConfig('doctrine', [ - 'orm' => [ - 'enable_lazy_ghost_objects' => true, - ], - ]); - } - if (class_exists(EntityValueResolver::class)) { $container->prependExtensionConfig('doctrine', [ 'orm' => [ diff --git a/tests/baseline-ignore b/tests/baseline-ignore index bb59e40..8aaed04 100644 --- a/tests/baseline-ignore +++ b/tests/baseline-ignore @@ -8,3 +8,4 @@ %Calling Doctrine\\ORM\\Configuration::getAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0% %Calling Doctrine\\ORM\\Configuration::setProxyNamespace is deprecated and will not be possible in Doctrine ORM 4.0% %Since doctrine/doctrine-bundle 2.16: Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated% +%The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0.% diff --git a/tests/config/doctrine.yaml b/tests/config/doctrine.yaml new file mode 100644 index 0000000..ddadaa0 --- /dev/null +++ b/tests/config/doctrine.yaml @@ -0,0 +1,19 @@ +doctrine: + dbal: + default_connection: default + connections: + default: + driver: pdo_sqlite + path: '%kernel.cache_dir%/test.sqlite' + types: + dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType + orm: + naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware + auto_mapping: true + mappings: + App: + is_bundle: false + type: attribute + dir: '%kernel.project_dir%/tests/Entity' + prefix: 'Meilisearch\Bundle\Tests\Entity' + alias: App diff --git a/tests/config/config_old_proxy.yaml b/tests/config/doctrine_old_proxy.yaml similarity index 82% rename from tests/config/config_old_proxy.yaml rename to tests/config/doctrine_old_proxy.yaml index 87de9ee..55a8989 100644 --- a/tests/config/config_old_proxy.yaml +++ b/tests/config/doctrine_old_proxy.yaml @@ -1,8 +1,3 @@ -framework: - test: true - secret: 67d829bf61dc5f87a73fd814e2c9f629 - http_method_override: false - doctrine: dbal: default_connection: default @@ -14,7 +9,6 @@ doctrine: dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType orm: auto_generate_proxy_classes: true - report_fields_where_declared: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: true mappings: diff --git a/tests/config/config_php7.yaml b/tests/config/doctrine_php7.yaml similarity index 76% rename from tests/config/config_php7.yaml rename to tests/config/doctrine_php7.yaml index 7f690a2..ee4a73a 100644 --- a/tests/config/config_php7.yaml +++ b/tests/config/doctrine_php7.yaml @@ -1,13 +1,3 @@ -framework: - test: true - secret: 67d829bf61dc5f87a73fd814e2c9f629 - http_method_override: false - annotations: true - serializer: - enable_annotations: true - router: - utf8: true - doctrine: dbal: default_connection: default diff --git a/tests/config/config.yaml b/tests/config/doctrine_v2.yaml similarity index 83% rename from tests/config/config.yaml rename to tests/config/doctrine_v2.yaml index 5302d56..7abc037 100644 --- a/tests/config/config.yaml +++ b/tests/config/doctrine_v2.yaml @@ -1,8 +1,3 @@ -framework: - test: true - secret: 67d829bf61dc5f87a73fd814e2c9f629 - http_method_override: false - doctrine: dbal: default_connection: default @@ -15,7 +10,6 @@ doctrine: orm: enable_native_lazy_objects: true auto_generate_proxy_classes: false - report_fields_where_declared: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: true mappings: diff --git a/tests/config/framework.yaml b/tests/config/framework.yaml new file mode 100644 index 0000000..f94709a --- /dev/null +++ b/tests/config/framework.yaml @@ -0,0 +1,4 @@ +framework: + test: true + secret: 67d829bf61dc5f87a73fd814e2c9f629 + http_method_override: false