You are here

public function ClassMetadataTest::testMergeConstraintsKeepsPrivateMembersSeparate 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::testMergeConstraintsKeepsPrivateMembersSeparate()

File

vendor/symfony/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());
}