Skip to content

Commit dfc54f9

Browse files
committed
Merge branch '2.2' into 2.3
* 2.2: No Entity Manager defined exception fixed CS [Acl] Fix for issue #9433 [Validator] fix docblock typos [DependencyInjection] removed the unused Reference and Parameter classes use statements from the compiled container class Fix mistake in translation's service definition. if handler_id is identical to null fix CS fix Fixed ModelChoiceList tests in Propel1 bridge. [AclProvider] Fix incorrect behaviour when partial results returned from cache Check if the pipe array is empty before calling stream_select() re-factor Propel1 ModelChoiceList [Locale] fixed the failing test described in #9455 [Process] fix phpdoc and timeout of 0 bug #9445 [BrowserKit] fixed protocol-relative url redirection Conflicts: src/Symfony/Component/BrowserKit/Tests/ClientTest.php src/Symfony/Component/Locale/Tests/Stub/StubIntlDateFormatterTest.php
2 parents c66aaa9 + 3c5a863 commit dfc54f9

File tree

28 files changed

+624
-206
lines changed

28 files changed

+624
-206
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,50 @@ public function testAssociatedCompositeEntity()
367367
);
368368
$violationsList = $validator->validate($associated);
369369
}
370+
371+
public function testDedicatedEntityManagerNullObject()
372+
{
373+
$uniqueFields = array('name');
374+
$entityManagerName = 'foo';
375+
376+
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
377+
378+
$constraint = new UniqueEntity(array(
379+
'fields' => $uniqueFields,
380+
'em' => $entityManagerName,
381+
));
382+
383+
$uniqueValidator = new UniqueEntityValidator($registry);
384+
385+
$entity = new SingleIntIdEntity(1, null);
386+
387+
$this->setExpectedException(
388+
'Symfony\Component\Validator\Exception\ConstraintDefinitionException',
389+
'Object manager "foo" does not exist.'
390+
);
391+
392+
$uniqueValidator->validate($entity, $constraint);
393+
}
394+
395+
public function testEntityManagerNullObject()
396+
{
397+
$uniqueFields = array('name');
398+
399+
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
400+
401+
$constraint = new UniqueEntity(array(
402+
'fields' => $uniqueFields,
403+
));
404+
405+
$uniqueValidator = new UniqueEntityValidator($registry);
406+
407+
$entity = new SingleIntIdEntity(1, null);
408+
409+
$this->setExpectedException(
410+
'Symfony\Component\Validator\Exception\ConstraintDefinitionException',
411+
'Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity"'
412+
);
413+
414+
$uniqueValidator->validate($entity, $constraint);
415+
}
370416
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ public function validate($entity, Constraint $constraint)
6262

6363
if ($constraint->em) {
6464
$em = $this->registry->getManager($constraint->em);
65+
66+
if (!$em) {
67+
throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em));
68+
}
6569
} else {
6670
$em = $this->registry->getManagerForClass(get_class($entity));
71+
72+
if (!$em) {
73+
throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_class($entity)));
74+
}
6775
}
6876

6977
$className = $this->context->getClassName();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy