Skip to content

Commit 3b396f6

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: 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 [DoctrineBridge][Validator] >= 2.3 Pass association instead of ID as argument 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 [HttpKernel] Lookup the response even if the lock was released after 2 seconds
2 parents 4022604 + 427974e commit 3b396f6

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;
@@ -404,7 +403,7 @@ public function testAssociatedEntity()
404403

405404
$this->buildViolation('myMessage')
406405
->atPath('property.path.single')
407-
->setInvalidValue(1)
406+
->setInvalidValue($entity1)
408407
->assertRaised();
409408
}
410409

@@ -428,29 +427,6 @@ public function testAssociatedEntityWithNull()
428427
$this->assertNoViolation();
429428
}
430429

431-
/**
432-
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
433-
* @expectedExceptionMessage Associated entities are not allowed to have more than one identifier field
434-
*/
435-
public function testAssociatedCompositeEntity()
436-
{
437-
$constraint = new UniqueEntity(array(
438-
'message' => 'myMessage',
439-
'fields' => array('composite'),
440-
'em' => self::EM_NAME,
441-
));
442-
443-
$composite = new CompositeIntIdEntity(1, 1, 'test');
444-
$associated = new AssociationEntity();
445-
$associated->composite = $composite;
446-
447-
$this->em->persist($composite);
448-
$this->em->persist($associated);
449-
$this->em->flush();
450-
451-
$this->validator->validate($associated, $constraint);
452-
}
453-
454430
/**
455431
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
456432
* @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
@@ -97,17 +97,6 @@ public function validate($entity, Constraint $constraint)
9797
* getter methods in the Proxy are being bypassed.
9898
*/
9999
$em->initializeObject($criteria[$fieldName]);
100-
101-
$relatedClass = $em->getClassMetadata($class->getAssociationTargetClass($fieldName));
102-
$relatedId = $relatedClass->getIdentifierValues($criteria[$fieldName]);
103-
104-
if (count($relatedId) > 1) {
105-
throw new ConstraintDefinitionException(
106-
'Associated entities are not allowed to have more than one identifier field to be '.
107-
'part of a unique constraint in: '.$class->getName().'#'.$fieldName
108-
);
109-
}
110-
$criteria[$fieldName] = array_pop($relatedId);
111100
}
112101
}
113102

0 commit comments

Comments
 (0)