PATH:
opt
/
alt
/
php54
/
usr
/
share
/
pear
/
test
/
Validator
/
Symfony
/
Component
/
Validator
/
Tests
/
Constraints
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * 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\Constraint; use Symfony\Component\Validator\Constraints\AbstractComparisonValidator; class ComparisonTest_Class { protected $value; public function __construct($value) { $this->value = $value; } public function __toString() { return (string) $this->value; } } /** * @author Daniel Holmes <daniel@danielholmes.org> */ abstract class AbstractComparisonValidatorTestCase extends \PHPUnit_Framework_TestCase { private $validator; private $context; protected function setUp() { $this->validator = $this->createValidator(); $this->context = $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext') ->disableOriginalConstructor() ->getMock(); $this->validator->initialize($this->context); } /** * @return AbstractComparisonValidator */ abstract protected function createValidator(); public function testThrowsConstraintExceptionIfNoValueOrProperty() { $this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); $comparison = $this->createConstraint(array()); $this->validator->validate('some value', $comparison); } /** * @dataProvider provideValidComparisons * @param mixed $dirtyValue * @param mixed $comparisonValue */ public function testValidComparisonToValue($dirtyValue, $comparisonValue) { $this->context->expects($this->never()) ->method('addViolation'); $constraint = $this->createConstraint(array('value' => $comparisonValue)); $this->context->expects($this->any()) ->method('getPropertyPath') ->will($this->returnValue('property1')); $this->validator->validate($dirtyValue, $constraint); } /** * @return array */ abstract public function provideValidComparisons(); /** * @dataProvider provideInvalidComparisons * @param mixed $dirtyValue * @param mixed $comparedValue * @param mixed $comparedValueString * @param string $comparedValueType */ public function testInvalidComparisonToValue($dirtyValue, $comparedValue, $comparedValueString, $comparedValueType) { $constraint = $this->createConstraint(array('value' => $comparedValue)); $constraint->message = 'Constraint Message'; $this->context->expects($this->any()) ->method('getPropertyPath') ->will($this->returnValue('property1')); $this->context->expects($this->once()) ->method('addViolation') ->with('Constraint Message', array( '{{ value }}' => $comparedValueString, '{{ compared_value }}' => $comparedValueString, '{{ compared_value_type }}' => $comparedValueType )); $this->validator->validate($dirtyValue, $constraint); } /** * @return array */ abstract public function provideInvalidComparisons(); /** * @param array $options Options for the constraint * @return Constraint */ abstract protected function createConstraint(array $options); }
[-] LanguageValidatorTest.php
[edit]
[-] FileValidatorTest.php
[edit]
[-] CountValidatorArrayTest.php
[edit]
[-] LocaleValidatorTest.php
[edit]
[-] FileValidatorPathTest.php
[edit]
[-] CallbackValidatorTest.php
[edit]
[-] FalseValidatorTest.php
[edit]
[-] BlankValidatorTest.php
[edit]
[-] CollectionValidatorCustomArrayObjectTest.php
[edit]
[-] NotNullValidatorTest.php
[edit]
[-] AbstractComparisonValidatorTestCase.php
[edit]
[-] AllValidatorTest.php
[edit]
[-] LengthValidatorTest.php
[edit]
[-] NullValidatorTest.php
[edit]
[-] LuhnValidatorTest.php
[edit]
[-] IsbnValidatorTest.php
[edit]
[-] IssnValidatorTest.php
[edit]
[-] NotIdenticalToValidatorTest.php
[edit]
[-] IbanValidatorTest.php
[edit]
[-] NotEqualToValidatorTest.php
[edit]
[-] TimeValidatorTest.php
[edit]
[-] CardSchemeValidatorTest.php
[edit]
[-] CollectionValidatorArrayObjectTest.php
[edit]
[-] RegexValidatorTest.php
[edit]
[-] LessThanOrEqualValidatorTest.php
[edit]
[-] TypeValidatorTest.php
[edit]
[-] IdenticalToValidatorTest.php
[edit]
[+]
Fixtures
[-] GreaterThanOrEqualValidatorTest.php
[edit]
[-] CountryValidatorTest.php
[edit]
[-] FileValidatorObjectTest.php
[edit]
[-] CountValidatorCountableTest.php
[edit]
[-] GreaterThanValidatorTest.php
[edit]
[-] NotBlankValidatorTest.php
[edit]
[-] RangeValidatorTest.php
[edit]
[-] EqualToValidatorTest.php
[edit]
[-] CountValidatorTest.php
[edit]
[-] LessThanValidatorTest.php
[edit]
[-] DateValidatorTest.php
[edit]
[-] DateTimeValidatorTest.php
[edit]
[-] CollectionTest.php
[edit]
[-] ImageValidatorTest.php
[edit]
[-] TrueValidatorTest.php
[edit]
[-] EmailValidatorTest.php
[edit]
[-] ChoiceValidatorTest.php
[edit]
[-] UrlValidatorTest.php
[edit]
[-] CollectionValidatorTest.php
[edit]
[+]
..
[-] IpValidatorTest.php
[edit]
[-] AllTest.php
[edit]
[-] CollectionValidatorArrayTest.php
[edit]
[-] CurrencyValidatorTest.php
[edit]
[-] ValidTest.php
[edit]
[-] ExpressionValidatorTest.php
[edit]