* * 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:----mHWCkzD7LZqpYEVfOA8MSQyWfjUrBGTU/t2CaThj0zPRm3QUINWVMTaRvpOYzjDzlAPaYBpgTS7E5a19L3O1ZQlasq/5ETHUp5Ag8CwocAQzPvWXQNt0UaxxEWqh3zhphm+Tl7MPAc4uYmQ6frbHvopN+X6MQ0hub8cS8dHy+qNWSyez00AWTgprST8XFOmYchxUZoYRYE+wc16s43LCG46oajzcJ3pySRzmZKxsNxb/fmoT/l9eZu+q9xwZjRZVHpvXvuhEFhw6DghlFvwkG8NTpCp84O3vfJIrKgIP02XpQNBVYE1of8wJ7vYVkFCYXb9BmYJJvFWmlfRXdpH9Oy5lkHPd51tu20iDbyQ1FFrbUYDJxfV2aBdMmR4qxZFFmSTvIdveJN6h/fKAFbyn48Nrl+Pn2ClMrDiVhPWvAawyvWMVGTJAcMe398u0y3OrIQpTxZnDOs91O1gN1a3pinhncLYhF9oBiPGN5TIVLLd7mxnn7GCWM/sUFOLkzF426wIo904FDXMBl/F98GQwt6GcdC4wCcdVcjtJ4ZsYdQyaZGTc2i9bvDsGifM5q8R1Xe2sc8n2cn36W6yjSejsKAa+zJONpEKEM3EgTgFa65cru/H3EckeN4V63oAI3Tr1o/DW3apwIOrqH3w3cKROwZMLAyaQQsmenQhDooMjMhs=----ATTACHMENT:----OTkwOTAxNTc4OTc2OTAyNSAyNzAwMDU4Nzc3MDM0MzY4IDk3NzkxMTA5MzQ2NzMw