class IsNullValidatorTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Tests/Constraints/IsNullValidatorTest.php \Symfony\Component\Validator\Tests\Constraints\IsNullValidatorTest
Hierarchy
- class \Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest extends \Symfony\Component\Validator\Tests\Constraints\PHPUnit_Framework_TestCase
- class \Symfony\Component\Validator\Tests\Constraints\IsNullValidatorTest
Expanded class hierarchy of IsNullValidatorTest
File
- vendor/
symfony/ validator/ Tests/ Constraints/ IsNullValidatorTest.php, line 18
Namespace
Symfony\Component\Validator\Tests\ConstraintsView source
class IsNullValidatorTest extends AbstractConstraintValidatorTest {
protected function getApiVersion() {
return Validation::API_VERSION_2_5;
}
protected function createValidator() {
return new IsNullValidator();
}
public function testNullIsValid() {
$this->validator
->validate(null, new IsNull());
$this
->assertNoViolation();
}
/**
* @dataProvider getInvalidValues
*/
public function testInvalidValues($value, $valueAsString) {
$constraint = new IsNull(array(
'message' => 'myMessage',
));
$this->validator
->validate($value, $constraint);
$this
->buildViolation('myMessage')
->setParameter('{{ value }}', $valueAsString)
->assertRaised();
}
public function getInvalidValues() {
return array(
array(
0,
'0',
),
array(
false,
'false',
),
array(
true,
'true',
),
array(
'',
'""',
),
array(
'foo bar',
'"foo bar"',
),
array(
new \DateTime(),
'object',
),
array(
new \stdClass(),
'object',
),
array(
array(),
'array',
),
);
}
}