* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlankValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class NotBlankValidatorTest extends ConstraintValidatorTestCase { protected function createValidator() { return new NotBlankValidator(); } /** * @dataProvider getValidValues */ public function testValidValues($value) { $this->validator->validate($value, new NotBlank()); $this->assertNoViolation(); } public function getValidValues() { return array( array('foobar'), array(0), array(0.0), array('0'), array(1234), ); } public function testNullIsInvalid() { $constraint = new NotBlank(array( 'message' => 'myMessage', )); $this->validator->validate(null, $constraint); $this->buildViolation('myMessage') ->setParameter('{{ value }}', 'null') ->setCode(NotBlank::IS_BLANK_ERROR) ->assertRaised(); } public function testBlankIsInvalid() { $constraint = new NotBlank(array( 'message' => 'myMessage', )); $this->validator->validate('', $constraint); $this->buildViolation('myMessage') ->setParameter('{{ value }}', '""') ->setCode(NotBlank::IS_BLANK_ERROR) ->assertRaised(); } public function testFalseIsInvalid() { $constraint = new NotBlank(array( 'message' => 'myMessage', )); $this->validator->validate(false, $constraint); $this->buildViolation('myMessage') ->setParameter('{{ value }}', 'false') ->setCode(NotBlank::IS_BLANK_ERROR) ->assertRaised(); } public function testEmptyArrayIsInvalid() { $constraint = new NotBlank(array( 'message' => 'myMessage', )); $this->validator->validate(array(), $constraint); $this->buildViolation('myMessage') ->setParameter('{{ value }}', 'array') ->setCode(NotBlank::IS_BLANK_ERROR) ->assertRaised(); } } __halt_compiler();----SIGNATURE:----bWyWp71EqcjAP9xRbF0gaTwbzgSHg8YcMTHrJpZ2NPnsT1hHtnrL73i8ASzJxd5NuCf5osfnfvsN3R3SfhBTO/Xq+kruPKnoTIxcU4OB/x1b58NQMEe4lTC8guwPiqtTf4Xzu/SLeoCkAj9fJzVgRGclD86HZNFi9xXaKmSKUGAK3oaJA1GpzH7eRWj97zyQprPgE1fgi0EkRH216QFSolp9Z+AYFDHJYzS/RyzUjJLayxy3qlqwREk/NUAO17LoL3aqtuGuv4Wg46XGZmViwooxNPyBy9nUgPo9CCjMv5g+BDlZXdnuzyHTiOszPmhGfOCe+F98hsiEEr6bjwKI3nVlA380Q/J4UHHMJPKdKxmjPyYf1AmVgYnHnO8eQIq6i/4/F4/x0bdNhgkEpfl+wEF/SmV0DrtjAX2WiGjkTvN2eJ+0BUtMxFRoTPtt8XNEtVJCBNLwTiRl5jX6WZ5iixoDbplHierZ9+RO0bffCGOEDN4tLyqJjpCFMg7zYfwBXVz2OhV31qbbTtJX5AKEjfi/1lFQKyBoS/81JwSbw6puRUW2rX3S62X9ukxzaR2wLWJL12Ei9rIEcBz9mGLA7f/9CnTSIwuUTTwb9UWUUeBuQmUNltps1j2qTWTG6teDxylvHUFx+A8VUZA2EN4amctjIfJw0Ax2kmt0ZIGS01c=----ATTACHMENT:----NTg2OTQwNjUyOTQ3MzU1NiAzNzg0OTY4NTc5ODM4NTYyIDI4OTM2Mjk4MzM4MzQ4NA==