[Validator] add missing parent isset and add test

This commit is contained in:
Amrouche Hamza 2018-01-19 12:39:28 +01:00
parent 8e8ee09747
commit bcb79a39ef
No known key found for this signature in database
GPG Key ID: 6968F2785ED4F012
2 changed files with 20 additions and 0 deletions

View File

@ -214,6 +214,16 @@ abstract class Constraint
throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, get_class($this)), array($option));
}
/**
* @param string $option The option name
*
* @return bool
*/
public function __isset($option)
{
return 'groups' === $option;
}
/**
* Adds the given group if this constraint is in the Default group.
*

View File

@ -26,6 +26,16 @@ class FileTest extends TestCase
$this->assertSame($bytes, $file->maxSize);
$this->assertSame($binaryFormat, $file->binaryFormat);
$this->assertTrue($file->__isset('maxSize'));
}
public function testMagicIsset()
{
$file = new File(array('maxSize' => 1));
$this->assertTrue($file->__isset('maxSize'));
$this->assertTrue($file->__isset('groups'));
$this->assertFalse($file->__isset('toto'));
}
/**