You are here

public function ClassMetadataTest::testMergeConstraintsMergesMemberConstraints in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Tests/Mapping/ClassMetadataTest.php \Symfony\Component\Validator\Tests\Mapping\ClassMetadataTest::testMergeConstraintsMergesMemberConstraints()

File

vendor/symfony/validator/Tests/Mapping/ClassMetadataTest.php, line 133

Class

ClassMetadataTest

Namespace

Symfony\Component\Validator\Tests\Mapping

Code

public function testMergeConstraintsMergesMemberConstraints() {
  $parent = new ClassMetadata(self::PARENTCLASS);
  $parent
    ->addPropertyConstraint('firstName', new ConstraintA());
  $this->metadata
    ->mergeConstraints($parent);
  $this->metadata
    ->addPropertyConstraint('firstName', new ConstraintA());
  $constraints = array(
    new ConstraintA(array(
      'groups' => array(
        'Default',
        'EntityParent',
        'Entity',
      ),
    )),
    new ConstraintA(array(
      'groups' => array(
        'Default',
        'Entity',
      ),
    )),
  );
  $members = $this->metadata
    ->getPropertyMetadata('firstName');
  $this
    ->assertCount(1, $members);
  $this
    ->assertEquals(self::PARENTCLASS, $members[0]
    ->getClassName());
  $this
    ->assertEquals($constraints, $members[0]
    ->getConstraints());
}