Skip to content

Commit

Permalink
Merge branch '7.1' into 7.2
Browse files Browse the repository at this point in the history
* 7.1:
  [FrameworkBundle] Add missing `not-compromised-password` entry in XSD
  [AssetMapper] Fix CssCompiler matches url in comments
  Add support for doctrine/persistence 4
  Ensure TransportExceptionInterface populates stream debug data
  Fix typo in validators.sk.xlf
  [Mime] Fix body validity check in `Email` when using `Message::setBody()`
  Review Arabic translations for the validator
  Fixed mistakes in proper hebrew writing in the previous translation and confirmed the rest to be correct and in the same style.
  Review translation
  [Cache] Don't clear system caches on cache:clear
  [FrameworkBundle] Fix patching refs to the tmp warmup dir in files generated by optional cache warmers
  Mark Czech Validator translation as reviewed
  [PropertyInfo] Fix `TypeTest` duplicated assert
  [Validator] Fix `Url` constraint attribute assertion
  convert legacy types to TypeInfo types if getType() is not implemented
  [HtmlSanitizer] Avoid accessing non existent array key when checking for hosts validity
  Update validators.ar.xlf
  [DomCrawler] Make `ChoiceFormField::isDisabled` return `true` for unchecked disabled checkboxes
  • Loading branch information
xabbuh committed Jan 27, 2025
2 parents ed99d10 + b0247c2 commit 7a183fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Tests/ArgumentResolver/EntityValueResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,13 @@ private function createRegistry(?ObjectManager $manager = null): ManagerRegistry
->method('getManagerForClass')
->willReturn($manager);

$registry->expects($this->any())
->method('getManager')
->willReturn($manager);
if (null === $manager) {
$registry->method('getManager')
->willThrowException(new \InvalidArgumentException());
} else {
$registry->method('getManager')->willReturn($manager);
}


return $registry;
}
Expand Down
14 changes: 10 additions & 4 deletions Tests/Validator/Constraints/UniqueEntityValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ protected function setUp(): void
protected function createRegistryMock($em = null)
{
$registry = $this->createMock(ManagerRegistry::class);
$registry->expects($this->any())
->method('getManager')
->with($this->equalTo(self::EM_NAME))
->willReturn($em);

if (null === $em) {
$registry->method('getManager')
->with($this->equalTo(self::EM_NAME))
->willThrowException(new \InvalidArgumentException());
} else {
$registry->method('getManager')
->with($this->equalTo(self::EM_NAME))
->willReturn($em);
}

return $registry;
}
Expand Down
8 changes: 4 additions & 4 deletions Validator/Constraints/UniqueEntityValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function validate(mixed $value, Constraint $constraint): void
$entityClass = $constraint->entityClass ?? $value::class;

if ($constraint->em) {
$em = $this->registry->getManager($constraint->em);

if (!$em) {
throw new ConstraintDefinitionException(\sprintf('Object manager "%s" does not exist.', $constraint->em));
try {
$em = $this->registry->getManager($constraint->em);
} catch (\InvalidArgumentException $e) {
throw new ConstraintDefinitionException(\sprintf('Object manager "%s" does not exist.', $constraint->em), 0, $e);
}
} else {
$em = $this->registry->getManagerForClass($entityClass);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=8.2",
"doctrine/event-manager": "^2",
"doctrine/persistence": "^3.1",
"doctrine/persistence": "^3.1|^4",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0",
Expand Down

0 comments on commit 7a183fd

Please sign in to comment.