1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace Symfony\Tests\Components\Validator;
- require_once __DIR__.'/../../../../../bootstrap.php';
- use Symfony\Components\Validator\Constraints\NotNull;
- use Symfony\Components\Validator\Constraints\NotNullValidator;
- class NotNullValidatorTest extends \PHPUnit_Framework_TestCase
- {
- protected $validator;
- public function setUp()
- {
- $this->validator = new NotNullValidator();
- }
- /**
- * @dataProvider getValidValues
- */
- public function testValidValues($value)
- {
- $this->assertTrue($this->validator->isValid($value, new NotNull()));
- }
- public function getValidValues()
- {
- return array(
- array(0),
- array(false),
- array(true),
- array(''),
- );
- }
- public function testNullIsInvalid()
- {
- $constraint = new NotNull(array(
- 'message' => 'myMessage'
- ));
- $this->assertFalse($this->validator->isValid(null, $constraint));
- $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage');
- $this->assertEquals($this->validator->getMessageParameters(), array());
- }
- }
|