* * 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:----Gw1VOQBbYb3gfzICLBNqeXWQ2TqJobw0o5njbGtEg3LOx072ys7NFzDB5bf8r4g6FQjgJG5Nv0asYD8VabKNgLrgIVDLxXugTlwTXdXlMZ4/9eYWV3h2nDyFx0DfP6BgdSwdmd6lTm2lKocCEywhzIwwUOctSV3noLHGhk0xbfPDP3z4nrWMW7s3QwDOPdiF5t89EgoRGjmsp87hBE3YCEdVqz/745B4umFYOCiIi4t/mQrbUQMI0rZYmff6I0le9PS2Z9nO7AaSoANEx69CyUw0uG9dy75sTJEEqU+gvDmd+5lTAgyDprBM1qgZXeZcwr/vQhNsIdMyx8g+mCO1dVKCc+daqE3EoRcrQ26LBt8huLQNbf5ijTUCLrkk6x6bXnNL3hB/y4FgGYO1/1hmHBVVnO4gQQdmTU7r3GLh3aWQ0icCei8v9BZbkyFogHOhTuSECbYQU+CgHT7ZJtFHEDqgW3ot39j7Brge2njpJmXK5bVfhk8dTWffTDMUuaINZ+X7XeXWf3P615aZAC2Luovfw1Z9YHec0FApztha5Cf1+wEUv3A0cwrPipyTgutdYGW+5V8cV+L0beRYDBy+FJ6jLSQo7g75o5B65U4pW2LjqyJ0dweBaQpt13aQmjEuMLLvLn5nW9X+7yPV2wfKCvZLo1/hr8ARxFnnT1y9ZpI=----ATTACHMENT:----NzMwNjIyMDM1MDYwNTQyMCA5MDE1MjQzNTA1MTU4Mzc5IDIyNTY3NjQyNjUzMTcxMzM=