コード例 #1
0
 public function testThreeConstraintGroups()
 {
     $constraintGroupOne = new ConstraintGroup();
     $constraintGroupOne->addConstraint(BoolConstraint::create()->requiresTrue());
     $constraintGroupTwo = new ConstraintGroup();
     $constraintGroupTwo->addConstraint(IntConstraint::create()->setMinValue(1)->setMaxValue(1));
     $constraintGroupThree = new ConstraintGroup();
     $constraintGroupThree->addConstraint(NullConstraint::create());
     $passed = Validator::create('Test', 1)->addConstraintGroup($constraintGroupOne)->addConstraintGroup($constraintGroupTwo)->addConstraintGroup($constraintGroupThree)->validate()->hasPassed();
     $this->assertTrue($passed);
     $passed = Validator::create('Test', 0)->addConstraintGroup($constraintGroupOne)->addConstraintGroup($constraintGroupTwo)->addConstraintGroup($constraintGroupThree)->validate()->hasPassed();
     $this->assertFalse($passed);
     $passed = Validator::create('Test', true)->addConstraintGroup($constraintGroupOne)->addConstraintGroup($constraintGroupTwo)->addConstraintGroup($constraintGroupThree)->validate()->hasPassed();
     $this->assertTrue($passed);
     $passed = Validator::create('Test', false)->addConstraintGroup($constraintGroupOne)->addConstraintGroup($constraintGroupTwo)->addConstraintGroup($constraintGroupThree)->validate()->hasPassed();
     $this->assertFalse($passed);
     $passed = Validator::create('Test', null)->addConstraintGroup($constraintGroupOne)->addConstraintGroup($constraintGroupTwo)->addConstraintGroup($constraintGroupThree)->validate()->hasPassed();
     $this->assertTrue($passed);
 }
コード例 #2
0
 /**
  * Generate the ConstraintGroup the traditional way.
  */
 public function testIsBoolRequiresFalse()
 {
     $constraintGroup = new ConstraintGroup();
     $constraintGroup->addConstraint(BoolConstraint::create()->setRequiredValue(false));
     $this->runTestsWithConstraintGroupRequiresFalse($constraintGroup);
 }