Skip to content

Commit bedb2fc

Browse files
committed
Merge remote-tracking branch 'origin/2.16.x' into 2.17.x
2 parents fe2f404 + af6c3c2 commit bedb2fc

15 files changed

Lines changed: 80 additions & 52 deletions

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@
5252
"phpstan/phpstan": "2.1.1",
5353
"phpstan/phpstan-phpunit": "2.0.3",
5454
"phpstan/phpstan-strict-rules": "^2",
55-
"phpunit/phpunit": "^9.6.22",
55+
"phpunit/phpunit": "^10.5.53",
5656
"psr/log": "^1.1.4 || ^2.0 || ^3.0",
5757
"symfony/doctrine-messenger": "^6.4 || ^7.0",
5858
"symfony/expression-language": "^6.4 || ^7.0",
5959
"symfony/messenger": "^6.4 || ^7.0",
60-
"symfony/phpunit-bridge": "^7.2",
6160
"symfony/property-info": "^6.4 || ^7.0",
6261
"symfony/security-bundle": "^6.4 || ^7.0",
6362
"symfony/stopwatch": "^6.4 || ^7.0",

phpunit.xml.dist

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
colors="true"
44
bootstrap="tests/bootstrap.php"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
6+
displayDetailsOnTestsThatTriggerDeprecations="true"
7+
failOnDeprecation="true"
68
>
79
<testsuites>
810
<testsuite name="DoctrineBundle for the Symfony Framework">
@@ -11,16 +13,12 @@
1113
</testsuites>
1214

1315
<php>
14-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=./tests/baseline-ignore"/>
16+
<env name="DOCTRINE_DEPRECATIONS" value="trigger"/>
1517
</php>
1618

17-
<coverage>
19+
<source ignoreSuppressionOfDeprecations="true">
1820
<include>
1921
<directory>src</directory>
2022
</include>
21-
</coverage>
22-
23-
<listeners>
24-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
25-
</listeners>
23+
</source>
2624
</phpunit>

tests/CacheSchemaSubscriberTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\CacheSchemaSubscriberPass;
66
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
7+
use Doctrine\ORM\Configuration;
78
use Doctrine\ORM\EntityManagerInterface;
89
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
910
use Symfony\Component\DependencyInjection\Alias;
@@ -13,8 +14,11 @@
1314
use Symfony\Component\DependencyInjection\Reference;
1415

1516
use function interface_exists;
17+
use function method_exists;
1618
use function sys_get_temp_dir;
1719

20+
use const PHP_VERSION_ID;
21+
1822
class CacheSchemaSubscriberTest extends TestCase
1923
{
2024
public function testSchemaSubscriberWiring(): void
@@ -64,7 +68,12 @@ public function testSchemaSubscriberWiring(): void
6468
$extension->load([
6569
[
6670
'dbal' => [],
67-
'orm' => [],
71+
'orm' => [
72+
'controller_resolver' => ['auto_mapping' => false],
73+
/* @phpstan-ignore function.alreadyNarrowedType */
74+
] + (method_exists(Configuration::class, 'enableNativeLazyObjects') ? [
75+
'enable_native_lazy_objects' => PHP_VERSION_ID >= 80400,
76+
] : ['enable_lazy_ghost_objects' => true]),
6877
],
6978
], $container);
7079

tests/Command/ImportMappingDoctrineCommandTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Doctrine\ORM\EntityManagerInterface;
77
use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
88
use InvalidArgumentException;
9+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
910
use PHPUnit\Framework\TestCase;
1011
use Symfony\Bundle\FrameworkBundle\Console\Application;
1112
use Symfony\Component\Console\Tester\CommandTester;
@@ -17,7 +18,6 @@
1718
use function interface_exists;
1819
use function sys_get_temp_dir;
1920

20-
/** @group legacy */
2121
class ImportMappingDoctrineCommandTest extends TestCase
2222
{
2323
private TestKernel $kernel;
@@ -66,6 +66,7 @@ protected function tearDown(): void
6666
unset($this->kernel, $this->commandTester);
6767
}
6868

69+
#[WithoutErrorHandler]
6970
public function testExecuteXmlWithBundle(): void
7071
{
7172
$this->commandTester->execute(['name' => 'ImportMappingTestFooBundle']);
@@ -79,6 +80,7 @@ public function testExecuteXmlWithBundle(): void
7980
);
8081
}
8182

83+
#[WithoutErrorHandler]
8284
public function testExecuteAnnotationsWithBundle(): void
8385
{
8486
$this->commandTester->execute([
@@ -95,13 +97,15 @@ public function testExecuteAnnotationsWithBundle(): void
9597
);
9698
}
9799

100+
#[WithoutErrorHandler]
98101
public function testExecuteThrowsExceptionWithNamespaceAndNoPath(): void
99102
{
100103
$this->expectException(InvalidArgumentException::class);
101104
$this->expectExceptionMessage('The --path option is required');
102105
$this->commandTester->execute(['name' => 'Some\Namespace']);
103106
}
104107

108+
#[WithoutErrorHandler]
105109
public function testExecuteXmlWithNamespace(): void
106110
{
107111
$this->commandTester->execute([
@@ -118,6 +122,7 @@ public function testExecuteXmlWithNamespace(): void
118122
);
119123
}
120124

125+
#[WithoutErrorHandler]
121126
public function testExecuteAnnotationsWithNamespace(): void
122127
{
123128
$this->commandTester->execute([

tests/ConnectionFactoryTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
1010
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
1111
use InvalidArgumentException;
12+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
1213

1314
use function array_intersect_key;
1415
use function method_exists;
@@ -63,7 +64,7 @@ public function testDefaultCollationMySql(): void
6364
);
6465
}
6566

66-
/** @group legacy */
67+
#[WithoutErrorHandler]
6768
public function testCollateMapsToCollationForMySql(): void
6869
{
6970
$factory = new ConnectionFactory([]);
@@ -87,7 +88,7 @@ public function testCollateMapsToCollationForMySql(): void
8788
);
8889
}
8990

90-
/** @group legacy */
91+
#[WithoutErrorHandler]
9192
public function testConnectionOverrideOptions(): void
9293
{
9394
$params = [
@@ -172,7 +173,7 @@ public function testItThrowsWhenPassingMappingTypesTwice(): void
172173
(new ConnectionFactory())->createConnection(['driver' => 'pdo_sqlite'], null, [], []);
173174
}
174175

175-
/** @group legacy */
176+
#[WithoutErrorHandler]
176177
public function testPassingMappingTypesAsFourthArgumentIsDeprecatedWithDbal4(): void
177178
{
178179
if (method_exists(Connection::class, 'getEventManager')) {

tests/DependencyInjection/AbstractDoctrineExtensionTestCase.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use InvalidArgumentException;
2828
use LogicException;
2929
use PDO;
30+
use PHPUnit\Framework\Attributes\DataProvider;
31+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
3032
use PHPUnit\Framework\TestCase;
3133
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
3234
use Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator;
@@ -146,7 +148,7 @@ public function testDbalLoadFromXmlSingleConnections(): void
146148
$this->assertEquals('9.4.0', $config['serverVersion']);
147149
}
148150

149-
/** @group legacy */
151+
#[WithoutErrorHandler]
150152
public function testDbalLoadUrlOverride(): void
151153
{
152154
$container = $this->loadContainer('dbal_allow_url_override');
@@ -167,7 +169,7 @@ public function testDbalLoadUrlOverride(): void
167169
$this->assertFalse(isset($config['override_url']));
168170
}
169171

170-
/** @group legacy */
172+
#[WithoutErrorHandler]
171173
public function testDbalLoadPartialUrlOverrideSetsDefaults(): void
172174
{
173175
$container = $this->loadContainer('dbal_allow_partial_url_override');
@@ -281,7 +283,7 @@ public function testDbalLoadDisableTypeComments(): void
281283
$this->assertCount(0, $calls);
282284
}
283285

284-
/** @group legacy */
286+
#[WithoutErrorHandler]
285287
public function testDbalSchemaManagerFactory(): void
286288
{
287289
$container = $this->loadContainer('dbal_schema_manager_factory');
@@ -702,10 +704,8 @@ public function testSetTypedFieldMapper(): void
702704
$this->assertDICDefinitionMethodCallOnce($definition, 'setTypedFieldMapper', [0 => new Reference('doctrine.orm.typed_field_mapper.default')]);
703705
}
704706

705-
/**
706-
* @dataProvider cacheConfigProvider
707-
* @group legacy
708-
*/
707+
#[DataProvider('cacheConfigProvider')]
708+
#[WithoutErrorHandler]
709709
public function testCacheConfig(string|null $expectedClass, string $entityManagerName, string|null $cacheGetter): void
710710
{
711711
if (! interface_exists(EntityManagerInterface::class)) {
@@ -1183,7 +1183,7 @@ public function testDbalSchemaFilterNewConfig(): void
11831183
}
11841184
}
11851185

1186-
/** @group legacy */
1186+
#[WithoutErrorHandler]
11871187
public function testWellKnownSchemaFilterDefaultTables(): void
11881188
{
11891189
$container = $this->getContainer([]);
@@ -1206,7 +1206,7 @@ public function testWellKnownSchemaFilterDefaultTables(): void
12061206
$this->assertTrue($filter->__invoke('anything_else'));
12071207
}
12081208

1209-
/** @group legacy */
1209+
#[WithoutErrorHandler]
12101210
public function testWellKnownSchemaFilterOverriddenTables(): void
12111211
{
12121212
$container = $this->getContainer([]);
@@ -1444,7 +1444,7 @@ public function testDisableSchemaValidation(): void
14441444
$this->assertFalse($collectorDefinition->getArguments()[1]);
14451445
}
14461446

1447-
/** @group legacy */
1447+
#[WithoutErrorHandler]
14481448
public function testNativeLazyObjectsWithoutConfig(): void
14491449
{
14501450
if (! interface_exists(EntityManagerInterface::class)) {
@@ -1485,7 +1485,7 @@ public function testNativeLazyObjectsWithConfigTrue(): void
14851485
$this->assertTrue($entityManager->getConfiguration()->isNativeLazyObjectsEnabled());
14861486
}
14871487

1488-
/** @group legacy */
1488+
#[WithoutErrorHandler]
14891489
public function testNativeLazyObjectsWithConfigFalse(): void
14901490
{
14911491
if (! interface_exists(EntityManagerInterface::class)) {

tests/DependencyInjection/Compiler/CacheCompatibilityPassTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
99
use Doctrine\ORM\Cache\Region;
1010
use Doctrine\ORM\EntityManagerInterface;
11+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
12+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
1113
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1214
use Symfony\Component\Config\Loader\LoaderInterface;
1315
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -54,6 +56,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
5456
'doctrine',
5557
[
5658
'orm' => [
59+
'controller_resolver' => ['auto_mapping' => false],
5760
'query_cache_driver' => ['type' => 'service', 'id' => 'custom_cache_service'],
5861
'result_cache_driver' => ['type' => 'pool', 'pool' => 'doctrine.system_cache_pool'],
5962
'second_level_cache' => [
@@ -89,7 +92,12 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
8992
$loader->load(static function (ContainerBuilder $containerBuilder): void {
9093
$containerBuilder->loadFromExtension(
9194
'doctrine',
92-
['orm' => ['metadata_cache_driver' => ['type' => 'service', 'id' => 'custom_cache_service']]],
95+
[
96+
'orm' => [
97+
'controller_resolver' => ['auto_mapping' => false],
98+
'metadata_cache_driver' => ['type' => 'service', 'id' => 'custom_cache_service'],
99+
],
100+
],
93101
);
94102
$containerBuilder->setDefinition(
95103
'custom_cache_service',
@@ -100,7 +108,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
100108
})->boot();
101109
}
102110

103-
/** @group legacy */
111+
#[WithoutErrorHandler]
104112
public function testMetadataCacheConfigUsingNonPsr6ServiceDefinedByApplication(): void
105113
{
106114
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/1365');

tests/DependencyInjection/Compiler/EntityListenerPassTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use stdClass;
1313
use Symfony\Component\DependencyInjection\ContainerBuilder;
1414

15+
use function class_exists;
1516
use function interface_exists;
1617

1718
class EntityListenerPassTest extends TestCase
@@ -59,6 +60,13 @@ public function testEntityListenersAreRegistered(string|null $event, string|null
5960
/** @return iterable<array{0: ?string, 1: ?string, 2: ?string}> */
6061
public static function provideEvents(): iterable
6162
{
63+
if (! class_exists(Events::class)) {
64+
// If ORM is not available, return fake data to make the data provider valid
65+
yield 'Without ORM' => [null, null, null];
66+
67+
return;
68+
}
69+
6270
yield 'With event and matching method' => [Events::prePersist, null, null];
6371
yield 'Without event' => [null, null, null];
6472
yield 'With event and custom method' => [Events::postLoad, 'postLoadHandler', 'postLoadHandler'];

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
3939
use InvalidArgumentException;
4040
use LogicException;
41+
use PHPUnit\Framework\Attributes\DataProvider;
42+
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
4143
use PHPUnit\Framework\TestCase;
4244
use ReflectionClass;
4345
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
@@ -66,10 +68,10 @@
6668
class DoctrineExtensionTest extends TestCase
6769
{
6870
/**
69-
* https://github.com/doctrine/orm/pull/7953 needed, otherwise ORM classes we define services for trigger deprecations
70-
*
71-
* @group legacy
71+
* https://github.com/doctrine/orm/pull/7953 needed, otherwise ORM classes
72+
* we define services for trigger deprecations
7273
*/
74+
#[WithoutErrorHandler]
7375
public function testAutowiringAlias(): void
7476
{
7577
if (! interface_exists(EntityManagerInterface::class)) {
@@ -656,7 +658,7 @@ public function testSingleEntityManagerWithDefaultSecondLevelCacheConfiguration(
656658
$this->assertEquals('%doctrine.orm.second_level_cache.default_cache_factory.class%', $slcDefinition->getClass());
657659
}
658660

659-
/** @group legacy */
661+
#[WithoutErrorHandler]
660662
public function testSingleEntityManagerWithCustomSecondLevelCacheConfiguration(): void
661663
{
662664
if (! interface_exists(EntityManagerInterface::class)) {
@@ -1018,7 +1020,7 @@ public function testMessengerIntegrationWithoutDoctrineTransport(): void
10181020
$this->assertNotContains('messenger.transport_factory', $container->findTags());
10191021
}
10201022

1021-
/** @group legacy */
1023+
#[WithoutErrorHandler]
10221024
public function testInvalidCacheConfiguration(): void
10231025
{
10241026
if (! interface_exists(EntityManagerInterface::class)) {
@@ -1065,12 +1067,9 @@ public function testCacheConfiguration(string $expectedAliasName, string $expect
10651067
$this->assertEquals($expectedTarget, (string) $alias);
10661068
}
10671069

1068-
/**
1069-
* @param array{type: ?string, pool?: string, id?: string} $cacheConfig
1070-
*
1071-
* @dataProvider legacyCacheConfigurationProvider
1072-
* @group legacy
1073-
*/
1070+
/** @param array{type: ?string, pool?: string, id?: string} $cacheConfig */
1071+
#[DataProvider('legacyCacheConfigurationProvider')]
1072+
#[WithoutErrorHandler]
10741073
public function testLegacyCacheConfiguration(string $expectedAliasName, string $expectedAliasTarget, string $cacheName, array $cacheConfig): void
10751074
{
10761075
$this->testCacheConfiguration($expectedAliasName, $expectedAliasTarget, $cacheName, $cacheConfig);

tests/DependencyInjection/Fixtures/TestKernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
5454
'schema_manager_factory' => 'doctrine.dbal.default_schema_manager_factory',
5555
],
5656
'orm' => [
57+
'controller_resolver' => ['auto_mapping' => false],
5758
'auto_generate_proxy_classes' => true,
5859
'enable_lazy_ghost_objects' => true,
5960
/** @phpstan-ignore function.alreadyNarrowedType */

0 commit comments

Comments
 (0)