Example #1
0
 public function testIsGettingErrorMessage()
 {
     $constraint = new Enum(['foo', 'bar']);
     $this->assertFalse($constraint->validate('test'), 'The "test" value is not part of the Enum');
     $this->assertEquals('Invalid option for enum. Allowed options are: foo, bar', $constraint->getErrorMessage());
 }
Example #2
0
 public function testErrorMessageIsCustomizable()
 {
     $constraint = new Enum(['foo', 'bar'], 'CUSTOM!');
     $this->assertSame('[field] CUSTOM!', $constraint->getErrorMessage('field'));
 }