You are here

class CollectionTest in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/validator/Tests/Constraints/CollectionTest.php \Symfony\Component\Validator\Tests\Constraints\CollectionTest
  2. 8 vendor/phpdocumentor/reflection-docblock/tests/phpDocumentor/Reflection/DocBlock/Type/CollectionTest.php \phpDocumentor\Reflection\DocBlock\Type\CollectionTest
  3. 8 vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/CollectionTest.php \Doctrine\Tests\Common\Collections\CollectionTest
Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Tests/Constraints/CollectionTest.php \Symfony\Component\Validator\Tests\Constraints\CollectionTest

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Tests\Constraints\CollectionTest extends \Symfony\Component\Validator\Tests\Constraints\PHPUnit_Framework_TestCase

Expanded class hierarchy of CollectionTest

File

vendor/symfony/validator/Tests/Constraints/CollectionTest.php, line 23

Namespace

Symfony\Component\Validator\Tests\Constraints
View source
class CollectionTest extends \PHPUnit_Framework_TestCase {

  /**
   * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
   */
  public function testRejectInvalidFieldsOption() {
    new Collection(array(
      'fields' => 'foo',
    ));
  }

  /**
   * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
   */
  public function testRejectNonConstraints() {
    new Collection(array(
      'foo' => 'bar',
    ));
  }

  /**
   * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
   */
  public function testRejectValidConstraint() {
    new Collection(array(
      'foo' => new Valid(),
    ));
  }

  /**
   * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
   */
  public function testRejectValidConstraintWithinOptional() {
    new Collection(array(
      'foo' => new Optional(new Valid()),
    ));
  }

  /**
   * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
   */
  public function testRejectValidConstraintWithinRequired() {
    new Collection(array(
      'foo' => new Required(new Valid()),
    ));
  }
  public function testAcceptOptionalConstraintAsOneElementArray() {
    $collection1 = new Collection(array(
      'fields' => array(
        'alternate_email' => array(
          new Optional(new Email()),
        ),
      ),
    ));
    $collection2 = new Collection(array(
      'fields' => array(
        'alternate_email' => new Optional(new Email()),
      ),
    ));
    $this
      ->assertEquals($collection1, $collection2);
  }
  public function testAcceptRequiredConstraintAsOneElementArray() {
    $collection1 = new Collection(array(
      'fields' => array(
        'alternate_email' => array(
          new Required(new Email()),
        ),
      ),
    ));
    $collection2 = new Collection(array(
      'fields' => array(
        'alternate_email' => new Required(new Email()),
      ),
    ));
    $this
      ->assertEquals($collection1, $collection2);
  }

}

Members