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); }
public function testIsNull() { $constraintGroup = new ConstraintGroup(); $constraintGroup->addConstraint(NullConstraint::create()); $this->runIsNull($constraintGroup); }