Esempio n. 1
0
 public function testErrorMessageIsString()
 {
     $constraintGroup = new ConstraintGroup();
     $constraintGroup->addConstraint(StringConstraint::create());
     $validator = Validator::create('Test', 123123)->addConstraintGroup($constraintGroup)->validate();
     $passed = $validator->hasPassed();
     if (!$passed) {
         $error = $validator->getRequirementsString();
         $searchFor = "{$validator->getName()} must ";
         $trimmedError = trim(str_replace($searchFor, '', $error));
         $this->assertGreaterThan(0, strlen($trimmedError));
     }
 }
 public function testMaxLengthCheck()
 {
     $constraintGroup = new ConstraintGroup();
     $constraintGroup->addConstraint(StringConstraint::create()->setMaxLength(5));
     $this->runIsStringMaxLength($constraintGroup);
 }