public function testFailureWithMultiByte()
 {
     $constraint = new MinLengthConstraint(2);
     $validationResult = $constraint('ü');
     $this->assertFalse($validationResult->isSuccess());
     ValidationErrorAssertion::assertErrorMessages($this, $validationResult, ['error.min-length' => ['lengthLimit' => 2]]);
 }
 /**
  * @dataProvider invalidValueProvider
  * @param int|float|string $limit
  * @param int|float|string $value
  */
 public function testInvalidValues($limit, $value)
 {
     $constraint = new MinNumberConstraint($limit);
     $validationResult = $constraint($value);
     $this->assertFalse($validationResult->isSuccess());
     ValidationErrorAssertion::assertErrorMessages($this, $validationResult, ['error.min-number' => ['limit' => (string) $limit]]);
 }
示例#3
0
 public function testFailureWithInvalidUrl()
 {
     $constraint = new UrlConstraint();
     $validationResult = $constraint('foobar');
     $this->assertFalse($validationResult->isSuccess());
     ValidationErrorAssertion::assertErrorMessages($this, $validationResult, ['error.url' => []]);
 }
 public function testFailureWithEmptyString()
 {
     $constraint = new MaxLengthConstraint(1);
     $validationResult = $constraint('ab');
     $this->assertFalse($validationResult->isSuccess());
     ValidationErrorAssertion::assertErrorMessages($this, $validationResult, ['error.max-length' => ['lengthLimit' => 1]]);
 }
 /**
  * @dataProvider invalidStepProvider
  * @param int|float|string $step
  * @param int|float|string|null $base
  * @param int|float|string $value
  * @param string $lowValue
  * @param string $highValue
  */
 public function testInvalidSteps($step, $base, $value, string $lowValue, string $highValue)
 {
     $constraint = new StepNumberConstraint($step, $base);
     $validationResult = $constraint($value);
     $this->assertFalse($validationResult->isSuccess());
     ValidationErrorAssertion::assertErrorMessages($this, $validationResult, ['error.step-number' => ['lowValue' => $lowValue, 'highValue' => $highValue]]);
 }
 public function testMerge()
 {
     $validationResultA = new ValidationResult(new ValidationError('foo'));
     $validationResultB = new ValidationResult();
     $validationResultC = new ValidationResult(new ValidationError('bar'), new ValidationError('baz'));
     $validationResult = $validationResultA->merge($validationResultB)->merge($validationResultC);
     $this->assertFalse($validationResult->isSuccess());
     ValidationErrorAssertion::assertErrorMessages($this, $validationResult, ['foo' => [], 'bar' => [], 'baz' => []]);
 }