You are here

public function ClassMetadataTest::testMergeConstraintsMergesMemberConstraints in Plug 7

File

lib/Symfony/validator/Symfony/Component/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());
}