Exemple #1
0
 public function testIsGettingErrorMessage()
 {
     $constraint = new StringSize(3);
     $this->assertFalse($constraint->validate('ab'));
     $this->assertEquals(sprintf('[field] Content out of min/max limit sizes [3, %s]', PHP_INT_MAX), $constraint->getErrorMessage('field'));
     $constraint = new StringSize(3, 5);
     $this->assertFalse($constraint->validate('ab'));
     $this->assertEquals('[field] Content out of min/max limit sizes [3, 5]', $constraint->getErrorMessage('field'));
 }
Exemple #2
0
 public function testErrorMessageIsCustomizable()
 {
     $constraint = new StringSize(1, 2, 'CUSTOM!');
     $this->assertSame('[field] CUSTOM!', $constraint->getErrorMessage('field'));
 }