You are here

public function ClassMetadataTest::testMergeConstraintsKeepsPrivateMembersSeparate in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php, line 168

Class

ClassMetadataTest

Namespace

Symfony\Component\Validator\Tests\Mapping

Code

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