This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Validator/Constraints/NotBlankValidatorTest.php
2010-08-20 23:09:55 +02:00

55 lines
1.3 KiB
PHP

<?php
namespace Symfony\Tests\Component\Validator;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotBlankValidator;
class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase
{
protected $validator;
public function setUp()
{
$this->validator = new NotBlankValidator();
}
/**
* @dataProvider getInvalidValues
*/
public function testInvalidValues($date)
{
$this->assertTrue($this->validator->isValid($date, new NotBlank()));
}
public function getInvalidValues()
{
return array(
array('foobar'),
array(0),
array(false),
array(1234),
);
}
public function testNullIsInvalid()
{
$this->assertFalse($this->validator->isValid(null, new NotBlank()));
}
public function testBlankIsInvalid()
{
$this->assertFalse($this->validator->isValid('', new NotBlank()));
}
public function testSetMessage()
{
$constraint = new NotBlank(array(
'message' => 'myMessage'
));
$this->assertFalse($this->validator->isValid('', $constraint));
$this->assertEquals($this->validator->getMessageTemplate(), 'myMessage');
$this->assertEquals($this->validator->getMessageParameters(), array());
}
}