You are here

class LegacyElementMetadataTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Tests/Mapping/LegacyElementMetadataTest.php \Symfony\Component\Validator\Tests\Mapping\LegacyElementMetadataTest

@group legacy

Hierarchy

  • class \Symfony\Component\Validator\Tests\Mapping\LegacyElementMetadataTest extends \Symfony\Component\Validator\Tests\Mapping\PHPUnit_Framework_TestCase

Expanded class hierarchy of LegacyElementMetadataTest

File

vendor/symfony/validator/Tests/Mapping/LegacyElementMetadataTest.php, line 21

Namespace

Symfony\Component\Validator\Tests\Mapping
View source
class LegacyElementMetadataTest extends \PHPUnit_Framework_TestCase {
  protected $metadata;
  protected function setUp() {
    $this->metadata = new TestElementMetadata();
  }
  protected function tearDown() {
    $this->metadata = null;
  }
  public function testAddConstraints() {
    $this->metadata
      ->addConstraint($constraint1 = new ConstraintA());
    $this->metadata
      ->addConstraint($constraint2 = new ConstraintA());
    $this
      ->assertEquals(array(
      $constraint1,
      $constraint2,
    ), $this->metadata
      ->getConstraints());
  }
  public function testMultipleConstraintsOfTheSameType() {
    $constraint1 = new ConstraintA(array(
      'property1' => 'A',
    ));
    $constraint2 = new ConstraintA(array(
      'property1' => 'B',
    ));
    $this->metadata
      ->addConstraint($constraint1);
    $this->metadata
      ->addConstraint($constraint2);
    $this
      ->assertEquals(array(
      $constraint1,
      $constraint2,
    ), $this->metadata
      ->getConstraints());
  }
  public function testFindConstraintsByGroup() {
    $constraint1 = new ConstraintA(array(
      'groups' => 'TestGroup',
    ));
    $constraint2 = new ConstraintB();
    $this->metadata
      ->addConstraint($constraint1);
    $this->metadata
      ->addConstraint($constraint2);
    $this
      ->assertEquals(array(
      $constraint1,
    ), $this->metadata
      ->findConstraints('TestGroup'));
  }
  public function testSerialize() {
    $this->metadata
      ->addConstraint(new ConstraintA(array(
      'property1' => 'A',
    )));
    $this->metadata
      ->addConstraint(new ConstraintB(array(
      'groups' => 'TestGroup',
    )));
    $metadata = unserialize(serialize($this->metadata));
    $this
      ->assertEquals($this->metadata, $metadata);
  }

}

Members