You are here

class MemberMetadataTest in Zircon Profile 8

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

Hierarchy

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

Expanded class hierarchy of MemberMetadataTest

File

vendor/symfony/validator/Tests/Mapping/MemberMetadataTest.php, line 20

Namespace

Symfony\Component\Validator\Tests\Mapping
View source
class MemberMetadataTest extends \PHPUnit_Framework_TestCase {
  protected $metadata;
  protected function setUp() {
    $this->metadata = new TestMemberMetadata('Symfony\\Component\\Validator\\Tests\\Fixtures\\Entity', 'getLastName', 'lastName');
  }
  protected function tearDown() {
    $this->metadata = null;
  }

  /**
   * @group legacy
   */
  public function testLegacyAddValidSetsMemberToCascaded() {
    $result = $this->metadata
      ->addConstraint(new Valid());
    $this
      ->assertEquals(array(), $this->metadata
      ->getConstraints());
    $this
      ->assertEquals($result, $this->metadata);
    $this
      ->assertTrue($this->metadata
      ->isCascaded());
  }

  /**
   * @group legacy
   */
  public function testLegacyAddOtherConstraintDoesNotSetMemberToCascaded() {
    $result = $this->metadata
      ->addConstraint($constraint = new ConstraintA());
    $this
      ->assertEquals(array(
      $constraint,
    ), $this->metadata
      ->getConstraints());
    $this
      ->assertEquals($result, $this->metadata);
    $this
      ->assertFalse($this->metadata
      ->isCascaded());
  }
  public function testAddConstraintRequiresClassConstraints() {
    $this
      ->setExpectedException('Symfony\\Component\\Validator\\Exception\\ConstraintDefinitionException');
    $this->metadata
      ->addConstraint(new ClassConstraint());
  }
  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);
  }
  public function testSerializeCollectionCascaded() {
    $this->metadata
      ->addConstraint(new Valid(array(
      'traverse' => true,
    )));
    $metadata = unserialize(serialize($this->metadata));
    $this
      ->assertEquals($this->metadata, $metadata);
  }

  /**
   * @group legacy
   */
  public function testLegacySerializeCollectionCascadedDeeply() {
    $this->metadata
      ->addConstraint(new Valid(array(
      'traverse' => true,
    )));
    $metadata = unserialize(serialize($this->metadata));
    $this
      ->assertEquals($this->metadata, $metadata);
  }
  public function testSerializeCollectionNotCascaded() {
    $this->metadata
      ->addConstraint(new Valid(array(
      'traverse' => false,
    )));
    $metadata = unserialize(serialize($this->metadata));
    $this
      ->assertEquals($this->metadata, $metadata);
  }

}

Members