Skip to content

Commit 52bd2f2

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: fixed undefined variable Fixed the phpDoc of UserInterface fixed APCu dep version make apc class loader testable against apcu without apc bc layer Added support for the `0.0.0.0/0` trusted proxy fixed CS [DoctrineBridge][Validator] >= 2.3 Pass association instead of ID as argument Limit the max height/width of icons in the profiler menu added missing constant Added 451 status code Remove unnecessary code Allow absolute URLs to be displayed in the debug toolbar [ClassLoader] Use symfony/polyfill-apcu update upgrade files with CSRF related option info [TranslationUpdateCommand] fixed undefined resultMessage var. [HttpKernel] Lookup the response even if the lock was released after 2 seconds
2 parents 609b902 + 3b396f6 commit 52bd2f2

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Doctrine\Common\Persistence\ObjectManager;
1717
use Doctrine\Common\Persistence\ObjectRepository;
1818
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
19-
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity;
2019
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
2120
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
2221
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
@@ -398,7 +397,7 @@ public function testAssociatedEntity()
398397

399398
$this->buildViolation('myMessage')
400399
->atPath('property.path.single')
401-
->setInvalidValue(1)
400+
->setInvalidValue($entity1)
402401
->assertRaised();
403402
}
404403

@@ -422,29 +421,6 @@ public function testAssociatedEntityWithNull()
422421
$this->assertNoViolation();
423422
}
424423

425-
/**
426-
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
427-
* @expectedExceptionMessage Associated entities are not allowed to have more than one identifier field
428-
*/
429-
public function testAssociatedCompositeEntity()
430-
{
431-
$constraint = new UniqueEntity(array(
432-
'message' => 'myMessage',
433-
'fields' => array('composite'),
434-
'em' => self::EM_NAME,
435-
));
436-
437-
$composite = new CompositeIntIdEntity(1, 1, 'test');
438-
$associated = new AssociationEntity();
439-
$associated->composite = $composite;
440-
441-
$this->em->persist($composite);
442-
$this->em->persist($associated);
443-
$this->em->flush();
444-
445-
$this->validator->validate($associated, $constraint);
446-
}
447-
448424
/**
449425
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
450426
* @expectedExceptionMessage Object manager "foo" does not exist.

Validator/Constraints/UniqueEntityValidator.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,6 @@ public function validate($entity, Constraint $constraint)
9696
* getter methods in the Proxy are being bypassed.
9797
*/
9898
$em->initializeObject($criteria[$fieldName]);
99-
100-
$relatedClass = $em->getClassMetadata($class->getAssociationTargetClass($fieldName));
101-
$relatedId = $relatedClass->getIdentifierValues($criteria[$fieldName]);
102-
103-
if (count($relatedId) > 1) {
104-
throw new ConstraintDefinitionException(
105-
'Associated entities are not allowed to have more than one identifier field to be '.
106-
'part of a unique constraint in: '.$class->getName().'#'.$fieldName
107-
);
108-
}
109-
$criteria[$fieldName] = array_pop($relatedId);
11099
}
111100
}
112101

0 commit comments

Comments
 (0)