Skip to content

Commit b634c58

Browse files
committed
Test with Symfony 7.1 and leverage its features
1 parent e0324e1 commit b634c58

File tree

10 files changed

+78
-31
lines changed

10 files changed

+78
-31
lines changed

.github/workflows/tests.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ jobs:
2929
strategy:
3030
matrix:
3131
php-version: ['7.4', '8.1', '8.2', '8.3']
32-
sf-version: ['5.4', '6.4', '7.0']
32+
sf-version: ['5.4', '6.4', '7.0', '7.1']
3333
exclude:
3434
- php-version: '7.4'
3535
sf-version: '6.4'
3636
- php-version: '7.4'
3737
sf-version: '7.0'
38+
- php-version: '7.4'
39+
sf-version: '7.1'
3840
- php-version: '8.1'
3941
sf-version: '5.4'
4042
- php-version: '8.1'
4143
sf-version: '7.0'
44+
- php-version: '8.1'
45+
sf-version: '7.1'
4246
- php-version: '8.2'
4347
sf-version: '5.4'
4448
- php-version: '8.3'
@@ -48,24 +52,32 @@ jobs:
4852

4953
name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)
5054
steps:
51-
- uses: actions/checkout@v4
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
5258
- name: Install PHP
5359
uses: shivammathur/setup-php@v2
5460
with:
5561
php-version: ${{ matrix.php-version }}
56-
tools: composer:v2, flex
62+
tools: composer, flex
63+
5764
- name: Validate composer.json and composer.lock
5865
run: composer validate
59-
- name: Install dependencies
60-
env:
61-
SYMFONY_REQUIRE: '${{ matrix.sf-version }}.*'
62-
run: composer install --prefer-dist --no-progress
66+
6367
- name: Remove doctrine/annotations
6468
if: matrix.php-version != '7.4'
65-
run: |
66-
composer remove --dev doctrine/annotations
69+
run: sed -i '/doctrine\/annotations/d' composer.json
70+
71+
- name: Install dependencies
72+
uses: ramsey/composer-install@v3
73+
env:
74+
SYMFONY_REQUIRE: ${{ matrix.sf-version }}
75+
with:
76+
dependency-versions: 'highest'
77+
6778
- name: Run test suite
6879
run: composer test:unit -- --coverage-clover coverage.xml
80+
6981
- name: Upload coverage file
7082
uses: actions/upload-artifact@v4
7183
with:
@@ -87,7 +99,11 @@ jobs:
8799
run: composer validate
88100

89101
- name: Install dependencies
90-
run: composer install --prefer-dist --no-progress --quiet
102+
uses: ramsey/composer-install@v3
103+
env:
104+
SYMFONY_REQUIRE: 7.1
105+
with:
106+
composer-options: '--no-progress --quiet'
91107

92108
- name: PHP CS Fixer
93109
run: composer lint:check
@@ -96,7 +112,7 @@ jobs:
96112
run: composer phpmd
97113
continue-on-error: true
98114

99-
- name: PHPstan
115+
- name: PHPStan
100116
run: |
101117
vendor/bin/simple-phpunit --version
102118
composer phpstan

bors.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ status = [
44
'integration-tests (PHP 8.2) (Symfony 6.4.*)',
55
'integration-tests (PHP 8.3) (Symfony 6.4.*)',
66
'integration-tests (PHP 8.2) (Symfony 7.0.*)',
7+
'integration-tests (PHP 8.2) (Symfony 7.1.*)',
78
'integration-tests (PHP 8.3) (Symfony 7.0.*)',
9+
'integration-tests (PHP 8.3) (Symfony 7.1.*)',
810
'Code style'
911
]
1012
# 1 hour timeout

composer.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"require": {
2121
"php": "^7.4|^8.0",
2222
"ext-json": "*",
23-
"doctrine/doctrine-bundle": "^2.4",
23+
"doctrine/doctrine-bundle": "^2.10",
2424
"meilisearch/meilisearch-php": "^1.0.0",
2525
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
2626
"symfony/polyfill-php80": "^1.27",
@@ -29,20 +29,20 @@
2929
},
3030
"require-dev": {
3131
"doctrine/annotations": "^2.0",
32-
"doctrine/orm": "^2.9|^3.0",
32+
"doctrine/orm": "^2.12 || ^3.0",
3333
"matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0",
34-
"nyholm/psr7": "^1.5.1",
35-
"php-cs-fixer/shim": "^3.14",
36-
"phpmd/phpmd": "^2.13",
37-
"phpstan/extension-installer": "^1.2",
38-
"phpstan/phpstan": "^1.10.6",
39-
"phpstan/phpstan-doctrine": "^1.3.33",
40-
"phpstan/phpstan-phpunit": "^1.3.10",
41-
"phpstan/phpstan-symfony": "^1.2.23",
42-
"phpunit/php-code-coverage": "^9.2.26",
43-
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0",
34+
"nyholm/psr7": "^1.8.1",
35+
"php-cs-fixer/shim": "^3.58.1",
36+
"phpmd/phpmd": "^2.15",
37+
"phpstan/extension-installer": "^1.4.1",
38+
"phpstan/phpstan": "^1.11.4",
39+
"phpstan/phpstan-doctrine": "^1.4.3",
40+
"phpstan/phpstan-phpunit": "^1.4.0",
41+
"phpstan/phpstan-symfony": "^1.4.4",
42+
"phpunit/php-code-coverage": "^9.2.31",
43+
"symfony/doctrine-bridge": "^5.4.19 || ^6.0.7 || ^7.0",
4444
"symfony/http-client": "^5.4 || ^6.0 || ^7.0",
45-
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0",
45+
"symfony/phpunit-bridge": "^7.1",
4646
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
4747
},
4848
"autoload": {

src/DependencyInjection/MeilisearchExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
namespace Meilisearch\Bundle\DependencyInjection;
66

77
use Meilisearch\Bundle\MeilisearchBundle;
8+
use Meilisearch\Bundle\Services\UnixTimestampNormalizer;
89
use Symfony\Component\Config\FileLocator;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011
use Symfony\Component\DependencyInjection\Extension\Extension;
1112
use Symfony\Component\DependencyInjection\Loader;
1213
use Symfony\Component\DependencyInjection\Reference;
14+
use Symfony\Component\HttpKernel\Kernel;
1315

1416
final class MeilisearchExtension extends Extension
1517
{
@@ -53,6 +55,10 @@ public function load(array $configs, ContainerBuilder $container): void
5355
$container->findDefinition('meilisearch.service')
5456
->replaceArgument(0, new Reference($config['serializer']))
5557
->replaceArgument(2, $config);
58+
59+
if (Kernel::VERSION_ID >= 70100) {
60+
$container->removeDefinition(UnixTimestampNormalizer::class);
61+
}
5662
}
5763

5864
/**

src/SearchableEntity.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
use Doctrine\ORM\Mapping\ClassMetadata;
88
use Symfony\Component\Config\Definition\Exception\Exception;
9+
use Symfony\Component\HttpKernel\Kernel;
910
use Symfony\Component\Serializer\Exception\ExceptionInterface;
11+
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
1012
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
1113
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
1214

@@ -69,6 +71,11 @@ public function getSearchableArray(): array
6971
$context['groups'] = $this->normalizationGroups;
7072
}
7173

74+
if (Kernel::VERSION_ID >= 70100) {
75+
$context[DateTimeNormalizer::FORMAT_KEY] = 'U';
76+
$context[DateTimeNormalizer::CAST_KEY] = 'int';
77+
}
78+
7279
if ($this->entity instanceof NormalizableInterface && null !== $this->normalizer) {
7380
return $this->entity->normalize($this->normalizer, Searchable::NORMALIZATION_FORMAT, $context);
7481
}

tests/BaseKernelTestCase.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ protected function setUp(): void
3232
{
3333
self::bootKernel();
3434

35-
$this->entityManager = $this->get('doctrine.orm.entity_manager');
35+
try {
36+
$this->entityManager = $this->get('doctrine.orm.entity_manager');
37+
} catch (\Throwable $e) {
38+
echo $e->getTraceAsString();
39+
die;
40+
}
3641
$this->client = $this->get('meilisearch.client');
3742
$this->searchService = $this->get('meilisearch.service');
3843

tests/Kernel.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
99
use Doctrine\ORM\Configuration;
1010
use Meilisearch\Bundle\MeilisearchBundle;
11+
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
1112
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1213
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
1314
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -38,6 +39,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
3839
$container->prependExtensionConfig('doctrine', [
3940
'orm' => [
4041
'report_fields_where_declared' => true,
42+
'validate_xml_mapping' => true,
4143
],
4244
]);
4345
}
@@ -51,6 +53,16 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
5153
]);
5254
}
5355

56+
if (class_exists(EntityValueResolver::class)) {
57+
$container->prependExtensionConfig('doctrine', [
58+
'orm' => [
59+
'controller_resolver' => [
60+
'auto_mapping' => false,
61+
],
62+
],
63+
]);
64+
}
65+
5466
// @phpstan-ignore-next-line
5567
if (Kernel::VERSION_ID >= 60400) {
5668
$container->prependExtensionConfig('framework', [

tests/baseline-ignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
%SqlitePlatform::canEmulateSchemas\(\) is deprecated. \(SqlitePlatform.php:\d+ called by SchemaTool.php:\d+, https://github.com/doctrine/dbal/pull/4805, package doctrine/dbal\)%
99
%Doctrine\\DBAL\\Schema\\Table::getPrimaryKeyColumns is deprecated. Use getPrimaryKey\(\) and Index::getColumns\(\) instead. \(Table.php:\d+ called by Table.php:\d+, https://github.com/doctrine/dbal/pull/5731, package doctrine/dbal\)%
1010
%The annotation mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to the attribute or XML driver. \(AnnotationDriver.php:\d+ called by getDoctrine_Orm_DefaultAnnotationMetadataDriverService.php:20, https://github.com/doctrine/orm/issues/10098, package doctrine/orm\)%
11+
%The "Doctrine\\Bundle\\DoctrineBundle\\DependencyInjection\\DoctrineExtension::getMappingResourceConfigDirectory\(\)" method will require a new "string|null $bundleDir" argument in the next major version of its parent class "Symfony\\Bridge\\Doctrine\\DependencyInjection\\AbstractDoctrineExtension", not defining it is deprecated%
12+
%Doctrine\\DBAL\\Configuration::setResultCacheImpl is deprecated, call setResultCache\(\) instead%
13+
%Method Doctrine\\ORM\\Configuration::setQueryCacheImpl\(\) is deprecated and will be removed in Doctrine ORM 3.0. Use setQueryCache\(\) instead%
14+
%The "Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger" class implements "Doctrine\\DBAL\\Logging\\SQLLogger" that is deprecated%
15+
%Method "Symfony\\Component\\Console\\Command\\Command::execute\(\)%

tests/config/config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ doctrine:
1414
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
1515
orm:
1616
auto_generate_proxy_classes: true
17-
validate_xml_mapping: true
1817
report_fields_where_declared: true
1918
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
2019
auto_mapping: true
@@ -25,5 +24,3 @@ doctrine:
2524
dir: '%kernel.project_dir%/tests/Entity'
2625
prefix: 'Meilisearch\Bundle\Tests\Entity'
2726
alias: App
28-
controller_resolver:
29-
auto_mapping: false

tests/config/config_php7.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ doctrine:
1919
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
2020
orm:
2121
auto_generate_proxy_classes: true
22-
validate_xml_mapping: true
2322
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
2423
auto_mapping: true
2524
mappings:
@@ -29,5 +28,3 @@ doctrine:
2928
dir: '%kernel.project_dir%/tests/Entity'
3029
prefix: 'Meilisearch\Bundle\Tests\Entity'
3130
alias: App
32-
controller_resolver:
33-
auto_mapping: false

0 commit comments

Comments
 (0)