Content-Length: 406286 | pFad | http://github.com/symfony/symfony/commit/d0069f833e37885fbdf9f92cd64b82020baa0d5d

14 Add support for doctrine/persistence 4 · symfony/symfony@d0069f8 · GitHub
Skip to content

Commit d0069f8

Browse files
committed
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 d0069f8

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
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: 14 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
}
@@ -614,6 +620,10 @@ public function testValidateUniquenessWithArrayValue()
614620

615621
public function testDedicatedEntityManagerNullObject()
616622
{
623+
if (method_exists(ObjectManager::class, 'isUninitializedObject')) {
624+
$this->markTestSkipped('This test is not applicable to persistence 4');
625+
}
626+
617627
$constraint = new UniqueEntity([
618628
'message' => 'myMessage',
619629
'fields' => ['name'],

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/d0069f833e37885fbdf9f92cd64b82020baa0d5d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy