2010-06-24 09:40:05 +01:00
|
|
|
<?php
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2012-03-28 14:43:52 +01:00
|
|
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2011-03-26 13:52:25 +00:00
|
|
|
use Symfony\Component\Validator\Constraints\False;
|
|
|
|
use Symfony\Component\Validator\Constraints\FalseValidator;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2014-08-08 09:10:43 +01:00
|
|
|
class FalseValidatorTest extends AbstractConstraintValidatorTest
|
2010-06-24 09:40:05 +01:00
|
|
|
{
|
2014-08-08 09:10:43 +01:00
|
|
|
protected function createValidator()
|
2011-06-14 09:44:38 +01:00
|
|
|
{
|
2014-08-08 09:10:43 +01:00
|
|
|
return new FalseValidator();
|
2011-06-14 09:44:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
public function testNullIsValid()
|
|
|
|
{
|
2012-02-09 17:02:12 +00:00
|
|
|
$this->validator->validate(null, new False());
|
2014-08-08 09:10:43 +01:00
|
|
|
|
|
|
|
$this->assertNoViolation();
|
2010-06-24 10:24:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testFalseIsValid()
|
|
|
|
{
|
2012-02-09 17:02:12 +00:00
|
|
|
$this->validator->validate(false, new False());
|
2014-08-08 09:10:43 +01:00
|
|
|
|
|
|
|
$this->assertNoViolation();
|
2010-06-24 10:24:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testTrueIsInvalid()
|
|
|
|
{
|
2011-03-26 13:52:25 +00:00
|
|
|
$constraint = new False(array(
|
2014-09-21 19:53:12 +01:00
|
|
|
'message' => 'myMessage',
|
2010-06-24 10:24:08 +01:00
|
|
|
));
|
|
|
|
|
2012-02-09 17:02:12 +00:00
|
|
|
$this->validator->validate(true, $constraint);
|
2014-08-08 09:10:43 +01:00
|
|
|
|
|
|
|
$this->assertViolation('myMessage', array(
|
2014-09-21 19:53:12 +01:00
|
|
|
'{{ value }}' => 'true',
|
2014-08-08 09:10:43 +01:00
|
|
|
));
|
2010-06-24 10:24:08 +01:00
|
|
|
}
|
2011-06-08 18:56:59 +01:00
|
|
|
}
|