Content-Length: 431227 | pFad | http://github.com/symfony/symfony/commit/6c2017282bceb74ad4feb604646c6b56dc19b1d5

BD Add support for doctrine/persistence 4 · symfony/symfony@6c20172 · GitHub
Skip to content

Commit 6c20172

Browse files
greg0irefabpot
authored andcommitted
Add support for doctrine/persistence 4
v4 provides a guarantee that ManagerRegistry::getManager() returns an entity manager (as opposed to null). The tests need to be adjusted to reflect the behavior of the mocked dependency more accurately, as it is throwing an exception in case of a null manager for all three supported versions of the library.
1 parent 2fd8b08 commit 6c20172

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"ext-xml": "*",
4040
"friendsofphp/proxy-manager-lts": "^1.0.2",
4141
"doctrine/event-manager": "^1.2|^2",
42-
"doctrine/persistence": "^2.5|^3.1",
42+
"doctrine/persistence": "^2.5|^3.1|^4",
4343
"twig/twig": "^2.13|^3.0.4",
4444
"psr/cache": "^2.0|^3.0",
4545
"psr/clock": "^1.0",

src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,13 @@ private function createRegistry(?ObjectManager $manager = null): ManagerRegistry
415415
->method('getManagerForClass')
416416
->willReturn($manager);
417417

418-
$registry->expects($this->any())
419-
->method('getManager')
420-
->willReturn($manager);
418+
if (null === $manager) {
419+
$registry->method('getManager')
420+
->willThrowException(new \InvalidArgumentException());
421+
} else {
422+
$registry->method('getManager')->willReturn($manager);
423+
}
424+
421425

422426
return $registry;
423427
}

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ protected function setUp(): void
7676
protected function createRegistryMock($em = null)
7777
{
7878
$registry = $this->createMock(ManagerRegistry::class);
79-
$registry->expects($this->any())
80-
->method('getManager')
81-
->with($this->equalTo(self::EM_NAME))
82-
->willReturn($em);
79+
80+
if (null === $em) {
81+
$registry->method('getManager')
82+
->with($this->equalTo(self::EM_NAME))
83+
->willThrowException(new \InvalidArgumentException());
84+
} else {
85+
$registry->method('getManager')
86+
->with($this->equalTo(self::EM_NAME))
87+
->willReturn($em);
88+
}
8389

8490
return $registry;
8591
}

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public function validate(mixed $entity, Constraint $constraint)
6969
}
7070

7171
if ($constraint->em) {
72-
$em = $this->registry->getManager($constraint->em);
73-
74-
if (!$em) {
75-
throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em));
72+
try {
73+
$em = $this->registry->getManager($constraint->em);
74+
} catch (\InvalidArgumentException $e) {
75+
throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em), 0, $e);
7676
}
7777
} else {
7878
$em = $this->registry->getManagerForClass($entity::class);

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.1",
2020
"doctrine/event-manager": "^1.2|^2",
21-
"doctrine/persistence": "^2.5|^3.1",
21+
"doctrine/persistence": "^2.5|^3.1|^4",
2222
"symfony/deprecation-contracts": "^2.5|^3",
2323
"symfony/polyfill-ctype": "~1.8",
2424
"symfony/polyfill-mbstring": "~1.0",

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/symfony/symfony/commit/6c2017282bceb74ad4feb604646c6b56dc19b1d5

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy