Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
268
vendor/symfony/validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php
vendored
Normal file
268
vendor/symfony/validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php
vendored
Normal file
|
@ -0,0 +1,268 @@
|
|||
<?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\Intl\Util\IntlTestHelper;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class ComparisonTest_Class
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->value;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
||||
{
|
||||
$result = $comparisons;
|
||||
|
||||
// Duplicate all tests involving DateTime objects to be tested with
|
||||
// DateTimeImmutable objects as well
|
||||
foreach ($comparisons as $comparison) {
|
||||
$add = false;
|
||||
|
||||
foreach ($comparison as $i => $value) {
|
||||
if ($value instanceof \DateTime) {
|
||||
$comparison[$i] = new \DateTimeImmutable(
|
||||
$value->format('Y-m-d H:i:s.u e'),
|
||||
$value->getTimezone()
|
||||
);
|
||||
$add = true;
|
||||
} elseif ('DateTime' === $value) {
|
||||
$comparison[$i] = 'DateTimeImmutable';
|
||||
$add = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($add) {
|
||||
$result[] = $comparison;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function provideInvalidConstraintOptions()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array(array()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidConstraintOptions
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
* @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set.
|
||||
*/
|
||||
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
|
||||
{
|
||||
$this->createConstraint($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
* @expectedExceptionMessage requires only one of the "value" or "propertyPath" options to be set, not both.
|
||||
*/
|
||||
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
|
||||
{
|
||||
$this->createConstraint((array(
|
||||
'value' => 'value',
|
||||
'propertyPath' => 'propertyPath',
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideAllValidComparisons
|
||||
*
|
||||
* @param mixed $dirtyValue
|
||||
* @param mixed $comparisonValue
|
||||
*/
|
||||
public function testValidComparisonToValue($dirtyValue, $comparisonValue)
|
||||
{
|
||||
$constraint = $this->createConstraint(array('value' => $comparisonValue));
|
||||
|
||||
$this->validator->validate($dirtyValue, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function provideAllValidComparisons()
|
||||
{
|
||||
// The provider runs before setUp(), so we need to manually fix
|
||||
// the default timezone
|
||||
$this->setDefaultTimezone('UTC');
|
||||
|
||||
$comparisons = self::addPhp5Dot5Comparisons($this->provideValidComparisons());
|
||||
|
||||
$this->restoreDefaultTimezone();
|
||||
|
||||
return $comparisons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidComparisonsToPropertyPath
|
||||
*/
|
||||
public function testValidComparisonToPropertyPath($comparedValue)
|
||||
{
|
||||
$constraint = $this->createConstraint(array('propertyPath' => 'value'));
|
||||
|
||||
$object = new ComparisonTest_Class(5);
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate($comparedValue, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidComparisonsToPropertyPath
|
||||
*/
|
||||
public function testValidComparisonToPropertyPathOnArray($comparedValue)
|
||||
{
|
||||
$constraint = $this->createConstraint(array('propertyPath' => '[root][value]'));
|
||||
|
||||
$this->setObject(array('root' => array('value' => 5)));
|
||||
|
||||
$this->validator->validate($comparedValue, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testNoViolationOnNullObjectWithPropertyPath()
|
||||
{
|
||||
$constraint = $this->createConstraint(array('propertyPath' => 'propertyPath'));
|
||||
|
||||
$this->setObject(null);
|
||||
|
||||
$this->validator->validate('some data', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testInvalidValuePath()
|
||||
{
|
||||
$constraint = $this->createConstraint(array('propertyPath' => 'foo'));
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
} else {
|
||||
$this->setExpectedException(ConstraintDefinitionException::class, sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
}
|
||||
|
||||
$object = new ComparisonTest_Class(5);
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate(5, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
abstract public function provideValidComparisons();
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
abstract public function provideValidComparisonsToPropertyPath();
|
||||
|
||||
/**
|
||||
* @dataProvider provideAllInvalidComparisons
|
||||
*
|
||||
* @param mixed $dirtyValue
|
||||
* @param mixed $dirtyValueAsString
|
||||
* @param mixed $comparedValue
|
||||
* @param mixed $comparedValueString
|
||||
* @param string $comparedValueType
|
||||
*/
|
||||
public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType)
|
||||
{
|
||||
// Conversion of dates to string differs between ICU versions
|
||||
// Make sure we have the correct version loaded
|
||||
if ($dirtyValue instanceof \DateTime || $dirtyValue instanceof \DateTimeInterface) {
|
||||
IntlTestHelper::requireIntl($this, '57.1');
|
||||
}
|
||||
|
||||
$constraint = $this->createConstraint(array('value' => $comparedValue));
|
||||
$constraint->message = 'Constraint Message';
|
||||
|
||||
$this->validator->validate($dirtyValue, $constraint);
|
||||
|
||||
$this->buildViolation('Constraint Message')
|
||||
->setParameter('{{ value }}', $dirtyValueAsString)
|
||||
->setParameter('{{ compared_value }}', $comparedValueString)
|
||||
->setParameter('{{ compared_value_type }}', $comparedValueType)
|
||||
->setCode($this->getErrorCode())
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function provideAllInvalidComparisons()
|
||||
{
|
||||
// The provider runs before setUp(), so we need to manually fix
|
||||
// the default timezone
|
||||
$this->setDefaultTimezone('UTC');
|
||||
|
||||
$comparisons = self::addPhp5Dot5Comparisons($this->provideInvalidComparisons());
|
||||
|
||||
$this->restoreDefaultTimezone();
|
||||
|
||||
return $comparisons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
abstract public function provideInvalidComparisons();
|
||||
|
||||
/**
|
||||
* @param array|null $options Options for the constraint
|
||||
*
|
||||
* @return Constraint
|
||||
*/
|
||||
abstract protected function createConstraint(array $options = null);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getErrorCode()
|
||||
{
|
||||
}
|
||||
}
|
21
vendor/symfony/validator/Tests/Constraints/AbstractConstraintValidatorTest.php
vendored
Normal file
21
vendor/symfony/validator/Tests/Constraints/AbstractConstraintValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @deprecated Since Symfony 3.2, use ConstraintValidatorTestCase instead.
|
||||
*/
|
||||
abstract class AbstractConstraintValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
}
|
42
vendor/symfony/validator/Tests/Constraints/AllTest.php
vendored
Normal file
42
vendor/symfony/validator/Tests/Constraints/AllTest.php
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?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 PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\All;
|
||||
use Symfony\Component\Validator\Constraints\Valid;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class AllTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testRejectNonConstraints()
|
||||
{
|
||||
new All(array(
|
||||
'foo',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testRejectValidConstraint()
|
||||
{
|
||||
new All(array(
|
||||
new Valid(),
|
||||
));
|
||||
}
|
||||
}
|
88
vendor/symfony/validator/Tests/Constraints/AllValidatorTest.php
vendored
Normal file
88
vendor/symfony/validator/Tests/Constraints/AllValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?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\Constraints\All;
|
||||
use Symfony\Component\Validator\Constraints\AllValidator;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class AllValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new AllValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new All(new Range(array('min' => 4))));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testThrowsExceptionIfNotTraversable()
|
||||
{
|
||||
$this->validator->validate('foo.barbar', new All(new Range(array('min' => 4))));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidArguments
|
||||
*/
|
||||
public function testWalkSingleConstraint($array)
|
||||
{
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint));
|
||||
}
|
||||
|
||||
$this->validator->validate($array, new All($constraint));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidArguments
|
||||
*/
|
||||
public function testWalkMultipleConstraints($array)
|
||||
{
|
||||
$constraint1 = new Range(array('min' => 4));
|
||||
$constraint2 = new NotNull();
|
||||
|
||||
$constraints = array($constraint1, $constraint2);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint1, $constraint2));
|
||||
}
|
||||
|
||||
$this->validator->validate($array, new All($constraints));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidArguments()
|
||||
{
|
||||
return array(
|
||||
array(array(5, 6, 7)),
|
||||
array(new \ArrayObject(array(5, 6, 7))),
|
||||
);
|
||||
}
|
||||
}
|
107
vendor/symfony/validator/Tests/Constraints/BicValidatorTest.php
vendored
Normal file
107
vendor/symfony/validator/Tests/Constraints/BicValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?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\Constraints\Bic;
|
||||
use Symfony\Component\Validator\Constraints\BicValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class BicValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new BicValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Bic());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Bic());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidBics
|
||||
*/
|
||||
public function testValidBics($bic)
|
||||
{
|
||||
$this->validator->validate($bic, new Bic());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidBics()
|
||||
{
|
||||
// http://formvalidation.io/validators/bic/
|
||||
return array(
|
||||
array('ASPKAT2LXXX'),
|
||||
array('ASPKAT2L'),
|
||||
array('DSBACNBXSHA'),
|
||||
array('UNCRIT2B912'),
|
||||
array('DABADKKK'),
|
||||
array('RZOOAT2L303'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidBics
|
||||
*/
|
||||
public function testInvalidBics($bic, $code)
|
||||
{
|
||||
$constraint = new Bic(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($bic, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$bic.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidBics()
|
||||
{
|
||||
return array(
|
||||
array('DEUTD', Bic::INVALID_LENGTH_ERROR),
|
||||
array('ASPKAT2LXX', Bic::INVALID_LENGTH_ERROR),
|
||||
array('ASPKAT2LX', Bic::INVALID_LENGTH_ERROR),
|
||||
array('ASPKAT2LXXX1', Bic::INVALID_LENGTH_ERROR),
|
||||
array('DABADKK', Bic::INVALID_LENGTH_ERROR),
|
||||
array('1SBACNBXSHA', Bic::INVALID_BANK_CODE_ERROR),
|
||||
array('RZ00AT2L303', Bic::INVALID_BANK_CODE_ERROR),
|
||||
array('D2BACNBXSHA', Bic::INVALID_BANK_CODE_ERROR),
|
||||
array('DS3ACNBXSHA', Bic::INVALID_BANK_CODE_ERROR),
|
||||
array('DSB4CNBXSHA', Bic::INVALID_BANK_CODE_ERROR),
|
||||
array('DEUT12HH', Bic::INVALID_COUNTRY_CODE_ERROR),
|
||||
array('DSBAC6BXSHA', Bic::INVALID_COUNTRY_CODE_ERROR),
|
||||
array('DSBA5NBXSHA', Bic::INVALID_COUNTRY_CODE_ERROR),
|
||||
|
||||
// branch code error
|
||||
array('THISSVAL1D]', Bic::INVALID_CHARACTERS_ERROR),
|
||||
|
||||
// location code error
|
||||
array('DEUTDEF]', Bic::INVALID_CHARACTERS_ERROR),
|
||||
|
||||
// lower case values are invalid
|
||||
array('DeutAT2LXXX', Bic::INVALID_CASE_ERROR),
|
||||
array('DEUTAT2lxxx', Bic::INVALID_CASE_ERROR),
|
||||
);
|
||||
}
|
||||
}
|
65
vendor/symfony/validator/Tests/Constraints/BlankValidatorTest.php
vendored
Normal file
65
vendor/symfony/validator/Tests/Constraints/BlankValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?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\Constraints\Blank;
|
||||
use Symfony\Component\Validator\Constraints\BlankValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class BlankValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new BlankValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Blank());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testBlankIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Blank());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidValues
|
||||
*/
|
||||
public function testInvalidValues($value, $valueAsString)
|
||||
{
|
||||
$constraint = new Blank(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', $valueAsString)
|
||||
->setCode(Blank::NOT_BLANK_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
{
|
||||
return array(
|
||||
array('foobar', '"foobar"'),
|
||||
array(0, '0'),
|
||||
array(false, 'false'),
|
||||
array(1234, '1234'),
|
||||
);
|
||||
}
|
||||
}
|
256
vendor/symfony/validator/Tests/Constraints/CallbackValidatorTest.php
vendored
Normal file
256
vendor/symfony/validator/Tests/Constraints/CallbackValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,256 @@
|
|||
<?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\Callback;
|
||||
use Symfony\Component\Validator\Constraints\CallbackValidator;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class CallbackValidatorTest_Class
|
||||
{
|
||||
public static function validateCallback($object, ExecutionContextInterface $context)
|
||||
{
|
||||
$context->addViolation('Callback message', array('{{ value }}' => 'foobar'));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class CallbackValidatorTest_Object
|
||||
{
|
||||
public function validate(ExecutionContextInterface $context)
|
||||
{
|
||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function validateStatic($object, ExecutionContextInterface $context)
|
||||
{
|
||||
$context->addViolation('Static message', array('{{ value }}' => 'baz'));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class CallbackValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CallbackValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Callback());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testSingleMethod()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
$constraint = new Callback('validate');
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('My message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSingleMethodExplicitName()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
$constraint = new Callback(array('callback' => 'validate'));
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('My message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSingleStaticMethod()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
$constraint = new Callback('validateStatic');
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('Static message')
|
||||
->setParameter('{{ value }}', 'baz')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testClosure()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
$constraint = new Callback(function ($object, ExecutionContextInterface $context) {
|
||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('My message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testClosureNullObject()
|
||||
{
|
||||
$constraint = new Callback(function ($object, ExecutionContextInterface $context) {
|
||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->buildViolation('My message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testClosureExplicitName()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
$constraint = new Callback(array(
|
||||
'callback' => function ($object, ExecutionContextInterface $context) {
|
||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||
|
||||
return false;
|
||||
},
|
||||
));
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('My message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testArrayCallable()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
$constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback'));
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('Callback message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testArrayCallableNullObject()
|
||||
{
|
||||
$constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback'));
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->buildViolation('Callback message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testArrayCallableExplicitName()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
$constraint = new Callback(array(
|
||||
'callback' => array(__CLASS__.'_Class', 'validateCallback'),
|
||||
));
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('Callback message')
|
||||
->setParameter('{{ value }}', 'foobar')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testExpectValidMethods()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
|
||||
$this->validator->validate($object, new Callback(array('callback' => array('foobar'))));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testExpectValidCallbacks()
|
||||
{
|
||||
$object = new CallbackValidatorTest_Object();
|
||||
|
||||
$this->validator->validate($object, new Callback(array('callback' => array('foo', 'bar'))));
|
||||
}
|
||||
|
||||
public function testConstraintGetTargets()
|
||||
{
|
||||
$constraint = new Callback(array());
|
||||
$targets = array(Constraint::CLASS_CONSTRAINT, Constraint::PROPERTY_CONSTRAINT);
|
||||
|
||||
$this->assertEquals($targets, $constraint->getTargets());
|
||||
}
|
||||
|
||||
// Should succeed. Needed when defining constraints as annotations.
|
||||
public function testNoConstructorArguments()
|
||||
{
|
||||
$constraint = new Callback();
|
||||
|
||||
$this->assertSame(array(Constraint::CLASS_CONSTRAINT, Constraint::PROPERTY_CONSTRAINT), $constraint->getTargets());
|
||||
}
|
||||
|
||||
public function testAnnotationInvocationSingleValued()
|
||||
{
|
||||
$constraint = new Callback(array('value' => 'validateStatic'));
|
||||
|
||||
$this->assertEquals(new Callback('validateStatic'), $constraint);
|
||||
}
|
||||
|
||||
public function testAnnotationInvocationMultiValued()
|
||||
{
|
||||
$constraint = new Callback(array('value' => array(__CLASS__.'_Class', 'validateCallback')));
|
||||
|
||||
$this->assertEquals(new Callback(array(__CLASS__.'_Class', 'validateCallback')), $constraint);
|
||||
}
|
||||
|
||||
public function testPayloadIsPassedToCallback()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$payloadCopy = null;
|
||||
|
||||
$constraint = new Callback(array(
|
||||
'callback' => function ($object, ExecutionContextInterface $constraint, $payload) use (&$payloadCopy) {
|
||||
$payloadCopy = $payload;
|
||||
},
|
||||
'payload' => 'Hello world!',
|
||||
));
|
||||
$this->validator->validate($object, $constraint);
|
||||
$this->assertEquals('Hello world!', $payloadCopy);
|
||||
|
||||
$payloadCopy = null;
|
||||
$constraint = new Callback(array(
|
||||
'callback' => function ($object, ExecutionContextInterface $constraint, $payload) use (&$payloadCopy) {
|
||||
$payloadCopy = $payload;
|
||||
},
|
||||
));
|
||||
$this->validator->validate($object, $constraint);
|
||||
$this->assertNull($payloadCopy);
|
||||
}
|
||||
}
|
138
vendor/symfony/validator/Tests/Constraints/CardSchemeValidatorTest.php
vendored
Normal file
138
vendor/symfony/validator/Tests/Constraints/CardSchemeValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?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\Constraints\CardScheme;
|
||||
use Symfony\Component\Validator\Constraints\CardSchemeValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class CardSchemeValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CardSchemeValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new CardScheme(array('schemes' => array())));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new CardScheme(array('schemes' => array())));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidNumbers
|
||||
*/
|
||||
public function testValidNumbers($scheme, $number)
|
||||
{
|
||||
$this->validator->validate($number, new CardScheme(array('schemes' => $scheme)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidNumbers
|
||||
*/
|
||||
public function testInvalidNumbers($scheme, $number, $code)
|
||||
{
|
||||
$constraint = new CardScheme(array(
|
||||
'schemes' => $scheme,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($number, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', \is_string($number) ? '"'.$number.'"' : $number)
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getValidNumbers()
|
||||
{
|
||||
return array(
|
||||
array('AMEX', '378282246310005'),
|
||||
array('AMEX', '371449635398431'),
|
||||
array('AMEX', '378734493671000'),
|
||||
array('AMEX', '347298508610146'),
|
||||
array('CHINA_UNIONPAY', '6228888888888888'),
|
||||
array('CHINA_UNIONPAY', '62288888888888888'),
|
||||
array('CHINA_UNIONPAY', '622888888888888888'),
|
||||
array('CHINA_UNIONPAY', '6228888888888888888'),
|
||||
array('DINERS', '30569309025904'),
|
||||
array('DINERS', '36088894118515'),
|
||||
array('DINERS', '38520000023237'),
|
||||
array('DISCOVER', '6011111111111117'),
|
||||
array('DISCOVER', '6011000990139424'),
|
||||
array('INSTAPAYMENT', '6372476031350068'),
|
||||
array('INSTAPAYMENT', '6385537775789749'),
|
||||
array('INSTAPAYMENT', '6393440808445746'),
|
||||
array('JCB', '3530111333300000'),
|
||||
array('JCB', '3566002020360505'),
|
||||
array('JCB', '213112345678901'),
|
||||
array('JCB', '180012345678901'),
|
||||
array('LASER', '6304678107004080'),
|
||||
array('LASER', '6706440607428128629'),
|
||||
array('LASER', '6771656738314582216'),
|
||||
array('MAESTRO', '6759744069209'),
|
||||
array('MAESTRO', '5020507657408074712'),
|
||||
array('MAESTRO', '5612559223580173965'),
|
||||
array('MAESTRO', '6759744069209'),
|
||||
array('MAESTRO', '6594371785970435599'),
|
||||
array('MASTERCARD', '5555555555554444'),
|
||||
array('MASTERCARD', '5105105105105100'),
|
||||
array('MASTERCARD', '2221005555554444'),
|
||||
array('MASTERCARD', '2230000000000000'),
|
||||
array('MASTERCARD', '2300000000000000'),
|
||||
array('MASTERCARD', '2699999999999999'),
|
||||
array('MASTERCARD', '2709999999999999'),
|
||||
array('MASTERCARD', '2720995105105100'),
|
||||
array('VISA', '4111111111111111'),
|
||||
array('VISA', '4012888888881881'),
|
||||
array('VISA', '4222222222222'),
|
||||
array('VISA', '4917610000000000003'),
|
||||
array(array('AMEX', 'VISA'), '4111111111111111'),
|
||||
array(array('AMEX', 'VISA'), '378282246310005'),
|
||||
array(array('JCB', 'MASTERCARD'), '5105105105105100'),
|
||||
array(array('VISA', 'MASTERCARD'), '5105105105105100'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getInvalidNumbers()
|
||||
{
|
||||
return array(
|
||||
array('VISA', '42424242424242424242', CardScheme::INVALID_FORMAT_ERROR),
|
||||
array('AMEX', '357298508610146', CardScheme::INVALID_FORMAT_ERROR),
|
||||
array('DINERS', '31569309025904', CardScheme::INVALID_FORMAT_ERROR),
|
||||
array('DINERS', '37088894118515', CardScheme::INVALID_FORMAT_ERROR),
|
||||
array('INSTAPAYMENT', '6313440808445746', CardScheme::INVALID_FORMAT_ERROR),
|
||||
array('CHINA_UNIONPAY', '622888888888888', CardScheme::INVALID_FORMAT_ERROR),
|
||||
array('CHINA_UNIONPAY', '62288888888888888888', CardScheme::INVALID_FORMAT_ERROR),
|
||||
array('AMEX', '30569309025904', CardScheme::INVALID_FORMAT_ERROR), // DINERS number
|
||||
array('AMEX', 'invalid', CardScheme::NOT_NUMERIC_ERROR), // A string
|
||||
array('AMEX', 0, CardScheme::INVALID_FORMAT_ERROR), // a lone number
|
||||
array('AMEX', '0', CardScheme::INVALID_FORMAT_ERROR), // a lone number
|
||||
array('AMEX', '000000000000', CardScheme::INVALID_FORMAT_ERROR), // a lone number
|
||||
array('DINERS', '3056930', CardScheme::INVALID_FORMAT_ERROR), // only first part of the number
|
||||
array('DISCOVER', '1117', CardScheme::INVALID_FORMAT_ERROR), // only last 4 digits
|
||||
array('MASTERCARD', '2721001234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
|
||||
array('MASTERCARD', '2220991234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
|
||||
);
|
||||
}
|
||||
}
|
342
vendor/symfony/validator/Tests/Constraints/ChoiceValidatorTest.php
vendored
Normal file
342
vendor/symfony/validator/Tests/Constraints/ChoiceValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,342 @@
|
|||
<?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\Constraints\Choice;
|
||||
use Symfony\Component\Validator\Constraints\ChoiceValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
function choice_callback()
|
||||
{
|
||||
return array('foo', 'bar');
|
||||
}
|
||||
|
||||
class ChoiceValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new ChoiceValidator();
|
||||
}
|
||||
|
||||
public static function staticCallback()
|
||||
{
|
||||
return array('foo', 'bar');
|
||||
}
|
||||
|
||||
public function objectMethodCallback()
|
||||
{
|
||||
return array('foo', 'bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectArrayIfMultipleIsTrue()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array('foo', 'bar'),
|
||||
'multiple' => true,
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate('asdf', $constraint);
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(
|
||||
null,
|
||||
new Choice(
|
||||
array(
|
||||
'choices' => array('foo', 'bar'),
|
||||
'strict' => true,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testChoicesOrCallbackExpected()
|
||||
{
|
||||
$this->validator->validate('foobar', new Choice(array('strict' => true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testValidCallbackExpected()
|
||||
{
|
||||
$this->validator->validate('foobar', new Choice(array('callback' => 'abcd', 'strict' => true)));
|
||||
}
|
||||
|
||||
public function testValidChoiceArray()
|
||||
{
|
||||
$constraint = new Choice(array('choices' => array('foo', 'bar'), 'strict' => true));
|
||||
|
||||
$this->validator->validate('bar', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidChoiceCallbackFunction()
|
||||
{
|
||||
$constraint = new Choice(array('callback' => __NAMESPACE__.'\choice_callback', 'strict' => true));
|
||||
|
||||
$this->validator->validate('bar', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidChoiceCallbackClosure()
|
||||
{
|
||||
$constraint = new Choice(
|
||||
array(
|
||||
'strict' => true,
|
||||
'callback' => function () {
|
||||
return array('foo', 'bar');
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
$this->validator->validate('bar', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidChoiceCallbackStaticMethod()
|
||||
{
|
||||
$constraint = new Choice(array('callback' => array(__CLASS__, 'staticCallback'), 'strict' => true));
|
||||
|
||||
$this->validator->validate('bar', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidChoiceCallbackContextMethod()
|
||||
{
|
||||
// search $this for "staticCallback"
|
||||
$this->setObject($this);
|
||||
|
||||
$constraint = new Choice(array('callback' => 'staticCallback', 'strict' => true));
|
||||
|
||||
$this->validator->validate('bar', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidChoiceCallbackContextObjectMethod()
|
||||
{
|
||||
// search $this for "objectMethodCallback"
|
||||
$this->setObject($this);
|
||||
|
||||
$constraint = new Choice(array('callback' => 'objectMethodCallback', 'strict' => true));
|
||||
|
||||
$this->validator->validate('bar', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testMultipleChoices()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array('foo', 'bar', 'baz'),
|
||||
'multiple' => true,
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate(array('baz', 'bar'), $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testInvalidChoice()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array('foo', 'bar'),
|
||||
'message' => 'myMessage',
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate('baz', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"baz"')
|
||||
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testInvalidChoiceEmptyChoices()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
// May happen when the choices are provided dynamically, e.g. from
|
||||
// the DB or the model
|
||||
'choices' => array(),
|
||||
'message' => 'myMessage',
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate('baz', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"baz"')
|
||||
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testInvalidChoiceMultiple()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array('foo', 'bar'),
|
||||
'multipleMessage' => 'myMessage',
|
||||
'multiple' => true,
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate(array('foo', 'baz'), $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"baz"')
|
||||
->setInvalidValue('baz')
|
||||
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testTooFewChoices()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array('foo', 'bar', 'moo', 'maa'),
|
||||
'multiple' => true,
|
||||
'min' => 2,
|
||||
'minMessage' => 'myMessage',
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$value = array('foo');
|
||||
|
||||
$this->setValue($value);
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ limit }}', 2)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(2)
|
||||
->setCode(Choice::TOO_FEW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testTooManyChoices()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array('foo', 'bar', 'moo', 'maa'),
|
||||
'multiple' => true,
|
||||
'max' => 2,
|
||||
'maxMessage' => 'myMessage',
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$value = array('foo', 'bar', 'moo');
|
||||
|
||||
$this->setValue($value);
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ limit }}', 2)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(2)
|
||||
->setCode(Choice::TOO_MANY_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testNonStrict()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array(1, 2),
|
||||
'strict' => false,
|
||||
));
|
||||
|
||||
$this->validator->validate('2', $constraint);
|
||||
$this->validator->validate(2, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testStrictAllowsExactValue()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array(1, 2),
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate(2, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testStrictDisallowsDifferentType()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array(1, 2),
|
||||
'strict' => true,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('2', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"2"')
|
||||
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testNonStrictWithMultipleChoices()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array(1, 2, 3),
|
||||
'multiple' => true,
|
||||
'strict' => false,
|
||||
));
|
||||
|
||||
$this->validator->validate(array('2', 3), $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testStrictWithMultipleChoices()
|
||||
{
|
||||
$constraint = new Choice(array(
|
||||
'choices' => array(1, 2, 3),
|
||||
'multiple' => true,
|
||||
'strict' => true,
|
||||
'multipleMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(array(2, '3'), $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"3"')
|
||||
->setInvalidValue('3')
|
||||
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
113
vendor/symfony/validator/Tests/Constraints/CollectionTest.php
vendored
Normal file
113
vendor/symfony/validator/Tests/Constraints/CollectionTest.php
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?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 PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\Collection;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
use Symfony\Component\Validator\Constraints\Optional;
|
||||
use Symfony\Component\Validator\Constraints\Required;
|
||||
use Symfony\Component\Validator\Constraints\Valid;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class CollectionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testRejectInvalidFieldsOption()
|
||||
{
|
||||
new Collection(array(
|
||||
'fields' => 'foo',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testRejectNonConstraints()
|
||||
{
|
||||
new Collection(array(
|
||||
'foo' => 'bar',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testRejectValidConstraint()
|
||||
{
|
||||
new Collection(array(
|
||||
'foo' => new Valid(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testRejectValidConstraintWithinOptional()
|
||||
{
|
||||
new Collection(array(
|
||||
'foo' => new Optional(new Valid()),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testRejectValidConstraintWithinRequired()
|
||||
{
|
||||
new Collection(array(
|
||||
'foo' => new Required(new Valid()),
|
||||
));
|
||||
}
|
||||
|
||||
public function testAcceptOptionalConstraintAsOneElementArray()
|
||||
{
|
||||
$collection1 = new Collection(array(
|
||||
'fields' => array(
|
||||
'alternate_email' => array(
|
||||
new Optional(new Email()),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
$collection2 = new Collection(array(
|
||||
'fields' => array(
|
||||
'alternate_email' => new Optional(new Email()),
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertEquals($collection1, $collection2);
|
||||
}
|
||||
|
||||
public function testAcceptRequiredConstraintAsOneElementArray()
|
||||
{
|
||||
$collection1 = new Collection(array(
|
||||
'fields' => array(
|
||||
'alternate_email' => array(
|
||||
new Required(new Email()),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
$collection2 = new Collection(array(
|
||||
'fields' => array(
|
||||
'alternate_email' => new Required(new Email()),
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertEquals($collection1, $collection2);
|
||||
}
|
||||
}
|
20
vendor/symfony/validator/Tests/Constraints/CollectionValidatorArrayObjectTest.php
vendored
Normal file
20
vendor/symfony/validator/Tests/Constraints/CollectionValidatorArrayObjectTest.php
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?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;
|
||||
|
||||
class CollectionValidatorArrayObjectTest extends CollectionValidatorTest
|
||||
{
|
||||
public function prepareTestData(array $contents)
|
||||
{
|
||||
return new \ArrayObject($contents);
|
||||
}
|
||||
}
|
20
vendor/symfony/validator/Tests/Constraints/CollectionValidatorArrayTest.php
vendored
Normal file
20
vendor/symfony/validator/Tests/Constraints/CollectionValidatorArrayTest.php
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?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;
|
||||
|
||||
class CollectionValidatorArrayTest extends CollectionValidatorTest
|
||||
{
|
||||
public function prepareTestData(array $contents)
|
||||
{
|
||||
return $contents;
|
||||
}
|
||||
}
|
22
vendor/symfony/validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php
vendored
Normal file
22
vendor/symfony/validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?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\Tests\Fixtures\CustomArrayObject;
|
||||
|
||||
class CollectionValidatorCustomArrayObjectTest extends CollectionValidatorTest
|
||||
{
|
||||
public function prepareTestData(array $contents)
|
||||
{
|
||||
return new CustomArrayObject($contents);
|
||||
}
|
||||
}
|
384
vendor/symfony/validator/Tests/Constraints/CollectionValidatorTest.php
vendored
Normal file
384
vendor/symfony/validator/Tests/Constraints/CollectionValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,384 @@
|
|||
<?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\Constraints\Collection;
|
||||
use Symfony\Component\Validator\Constraints\CollectionValidator;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Constraints\Optional;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Constraints\Required;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
abstract class CollectionValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CollectionValidator();
|
||||
}
|
||||
|
||||
abstract protected function prepareTestData(array $contents);
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Collection(array('fields' => array(
|
||||
'foo' => new Range(array('min' => 4)),
|
||||
))));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFieldsAsDefaultOption()
|
||||
{
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$data = $this->prepareTestData(array('foo' => 'foobar'));
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => $constraint,
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testThrowsExceptionIfNotTraversable()
|
||||
{
|
||||
$this->validator->validate('foobar', new Collection(array('fields' => array(
|
||||
'foo' => new Range(array('min' => 4)),
|
||||
))));
|
||||
}
|
||||
|
||||
public function testWalkSingleConstraint()
|
||||
{
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$array = array(
|
||||
'foo' => 3,
|
||||
'bar' => 5,
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint));
|
||||
}
|
||||
|
||||
$data = $this->prepareTestData($array);
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraint,
|
||||
'bar' => $constraint,
|
||||
),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testWalkMultipleConstraints()
|
||||
{
|
||||
$constraints = array(
|
||||
new Range(array('min' => 4)),
|
||||
new NotNull(),
|
||||
);
|
||||
|
||||
$array = array(
|
||||
'foo' => 3,
|
||||
'bar' => 5,
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$this->expectValidateValueAt($i++, '['.$key.']', $value, $constraints);
|
||||
}
|
||||
|
||||
$data = $this->prepareTestData($array);
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraints,
|
||||
'bar' => $constraints,
|
||||
),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testExtraFieldsDisallowed()
|
||||
{
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$data = $this->prepareTestData(array(
|
||||
'foo' => 5,
|
||||
'baz' => 6,
|
||||
));
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraint,
|
||||
),
|
||||
'extraFieldsMessage' => 'myMessage',
|
||||
)));
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ field }}', '"baz"')
|
||||
->atPath('property.path[baz]')
|
||||
->setInvalidValue(6)
|
||||
->setCode(Collection::NO_SUCH_FIELD_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
// bug fix
|
||||
public function testNullNotConsideredExtraField()
|
||||
{
|
||||
$data = $this->prepareTestData(array(
|
||||
'foo' => null,
|
||||
));
|
||||
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraint,
|
||||
),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testExtraFieldsAllowed()
|
||||
{
|
||||
$data = $this->prepareTestData(array(
|
||||
'foo' => 5,
|
||||
'bar' => 6,
|
||||
));
|
||||
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraint,
|
||||
),
|
||||
'allowExtraFields' => true,
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testMissingFieldsDisallowed()
|
||||
{
|
||||
$data = $this->prepareTestData(array());
|
||||
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraint,
|
||||
),
|
||||
'missingFieldsMessage' => 'myMessage',
|
||||
)));
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ field }}', '"foo"')
|
||||
->atPath('property.path[foo]')
|
||||
->setInvalidValue(null)
|
||||
->setCode(Collection::MISSING_FIELD_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testMissingFieldsAllowed()
|
||||
{
|
||||
$data = $this->prepareTestData(array());
|
||||
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraint,
|
||||
),
|
||||
'allowMissingFields' => true,
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testOptionalFieldPresent()
|
||||
{
|
||||
$data = $this->prepareTestData(array(
|
||||
'foo' => null,
|
||||
));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => new Optional(),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testOptionalFieldNotPresent()
|
||||
{
|
||||
$data = $this->prepareTestData(array());
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => new Optional(),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testOptionalFieldSingleConstraint()
|
||||
{
|
||||
$array = array(
|
||||
'foo' => 5,
|
||||
);
|
||||
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint));
|
||||
|
||||
$data = $this->prepareTestData($array);
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => new Optional($constraint),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testOptionalFieldMultipleConstraints()
|
||||
{
|
||||
$array = array(
|
||||
'foo' => 5,
|
||||
);
|
||||
|
||||
$constraints = array(
|
||||
new NotNull(),
|
||||
new Range(array('min' => 4)),
|
||||
);
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints);
|
||||
|
||||
$data = $this->prepareTestData($array);
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => new Optional($constraints),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testRequiredFieldPresent()
|
||||
{
|
||||
$data = $this->prepareTestData(array(
|
||||
'foo' => null,
|
||||
));
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => new Required(),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testRequiredFieldNotPresent()
|
||||
{
|
||||
$data = $this->prepareTestData(array());
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => new Required(),
|
||||
),
|
||||
'missingFieldsMessage' => 'myMessage',
|
||||
)));
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ field }}', '"foo"')
|
||||
->atPath('property.path[foo]')
|
||||
->setInvalidValue(null)
|
||||
->setCode(Collection::MISSING_FIELD_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testRequiredFieldSingleConstraint()
|
||||
{
|
||||
$array = array(
|
||||
'foo' => 5,
|
||||
);
|
||||
|
||||
$constraint = new Range(array('min' => 4));
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint));
|
||||
|
||||
$data = $this->prepareTestData($array);
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => new Required($constraint),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testRequiredFieldMultipleConstraints()
|
||||
{
|
||||
$array = array(
|
||||
'foo' => 5,
|
||||
);
|
||||
|
||||
$constraints = array(
|
||||
new NotNull(),
|
||||
new Range(array('min' => 4)),
|
||||
);
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints);
|
||||
|
||||
$data = $this->prepareTestData($array);
|
||||
|
||||
$this->validator->validate($data, new Collection(array(
|
||||
'foo' => new Required($constraints),
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testObjectShouldBeLeftUnchanged()
|
||||
{
|
||||
$value = new \ArrayObject(array(
|
||||
'foo' => 3,
|
||||
));
|
||||
|
||||
$constraint = new Range(array('min' => 2));
|
||||
|
||||
$this->expectValidateValueAt(0, '[foo]', $value['foo'], array($constraint));
|
||||
|
||||
$this->validator->validate($value, new Collection(array(
|
||||
'fields' => array(
|
||||
'foo' => $constraint,
|
||||
),
|
||||
)));
|
||||
|
||||
$this->assertEquals(array(
|
||||
'foo' => 3,
|
||||
), (array) $value);
|
||||
}
|
||||
}
|
148
vendor/symfony/validator/Tests/Constraints/CompositeTest.php
vendored
Normal file
148
vendor/symfony/validator/Tests/Constraints/CompositeTest.php
vendored
Normal file
|
@ -0,0 +1,148 @@
|
|||
<?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 PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\Composite;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Constraints\Valid;
|
||||
|
||||
class ConcreteComposite extends Composite
|
||||
{
|
||||
public $constraints;
|
||||
|
||||
protected function getCompositeOption()
|
||||
{
|
||||
return 'constraints';
|
||||
}
|
||||
|
||||
public function getDefaultOption()
|
||||
{
|
||||
return 'constraints';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class CompositeTest extends TestCase
|
||||
{
|
||||
public function testMergeNestedGroupsIfNoExplicitParentGroup()
|
||||
{
|
||||
$constraint = new ConcreteComposite(array(
|
||||
new NotNull(array('groups' => 'Default')),
|
||||
new NotBlank(array('groups' => array('Default', 'Strict'))),
|
||||
));
|
||||
|
||||
$this->assertEquals(array('Default', 'Strict'), $constraint->groups);
|
||||
$this->assertEquals(array('Default'), $constraint->constraints[0]->groups);
|
||||
$this->assertEquals(array('Default', 'Strict'), $constraint->constraints[1]->groups);
|
||||
}
|
||||
|
||||
public function testSetImplicitNestedGroupsIfExplicitParentGroup()
|
||||
{
|
||||
$constraint = new ConcreteComposite(array(
|
||||
'constraints' => array(
|
||||
new NotNull(),
|
||||
new NotBlank(),
|
||||
),
|
||||
'groups' => array('Default', 'Strict'),
|
||||
));
|
||||
|
||||
$this->assertEquals(array('Default', 'Strict'), $constraint->groups);
|
||||
$this->assertEquals(array('Default', 'Strict'), $constraint->constraints[0]->groups);
|
||||
$this->assertEquals(array('Default', 'Strict'), $constraint->constraints[1]->groups);
|
||||
}
|
||||
|
||||
public function testExplicitNestedGroupsMustBeSubsetOfExplicitParentGroups()
|
||||
{
|
||||
$constraint = new ConcreteComposite(array(
|
||||
'constraints' => array(
|
||||
new NotNull(array('groups' => 'Default')),
|
||||
new NotBlank(array('groups' => 'Strict')),
|
||||
),
|
||||
'groups' => array('Default', 'Strict'),
|
||||
));
|
||||
|
||||
$this->assertEquals(array('Default', 'Strict'), $constraint->groups);
|
||||
$this->assertEquals(array('Default'), $constraint->constraints[0]->groups);
|
||||
$this->assertEquals(array('Strict'), $constraint->constraints[1]->groups);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testFailIfExplicitNestedGroupsNotSubsetOfExplicitParentGroups()
|
||||
{
|
||||
new ConcreteComposite(array(
|
||||
'constraints' => array(
|
||||
new NotNull(array('groups' => array('Default', 'Foobar'))),
|
||||
),
|
||||
'groups' => array('Default', 'Strict'),
|
||||
));
|
||||
}
|
||||
|
||||
public function testImplicitGroupNamesAreForwarded()
|
||||
{
|
||||
$constraint = new ConcreteComposite(array(
|
||||
new NotNull(array('groups' => 'Default')),
|
||||
new NotBlank(array('groups' => 'Strict')),
|
||||
));
|
||||
|
||||
$constraint->addImplicitGroupName('ImplicitGroup');
|
||||
|
||||
$this->assertEquals(array('Default', 'Strict', 'ImplicitGroup'), $constraint->groups);
|
||||
$this->assertEquals(array('Default', 'ImplicitGroup'), $constraint->constraints[0]->groups);
|
||||
$this->assertEquals(array('Strict'), $constraint->constraints[1]->groups);
|
||||
}
|
||||
|
||||
public function testSingleConstraintsAccepted()
|
||||
{
|
||||
$nestedConstraint = new NotNull();
|
||||
$constraint = new ConcreteComposite($nestedConstraint);
|
||||
|
||||
$this->assertEquals(array($nestedConstraint), $constraint->constraints);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testFailIfNoConstraint()
|
||||
{
|
||||
new ConcreteComposite(array(
|
||||
new NotNull(array('groups' => 'Default')),
|
||||
'NotBlank',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testFailIfNoConstraintObject()
|
||||
{
|
||||
new ConcreteComposite(array(
|
||||
new NotNull(array('groups' => 'Default')),
|
||||
new \ArrayObject(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testValidCantBeNested()
|
||||
{
|
||||
new ConcreteComposite(array(
|
||||
new Valid(),
|
||||
));
|
||||
}
|
||||
}
|
23
vendor/symfony/validator/Tests/Constraints/CountValidatorArrayTest.php
vendored
Normal file
23
vendor/symfony/validator/Tests/Constraints/CountValidatorArrayTest.php
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class CountValidatorArrayTest extends CountValidatorTest
|
||||
{
|
||||
protected function createCollection(array $content)
|
||||
{
|
||||
return $content;
|
||||
}
|
||||
}
|
25
vendor/symfony/validator/Tests/Constraints/CountValidatorCountableTest.php
vendored
Normal file
25
vendor/symfony/validator/Tests/Constraints/CountValidatorCountableTest.php
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?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\Tests\Fixtures\Countable;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class CountValidatorCountableTest extends CountValidatorTest
|
||||
{
|
||||
protected function createCollection(array $content)
|
||||
{
|
||||
return new Countable($content);
|
||||
}
|
||||
}
|
198
vendor/symfony/validator/Tests/Constraints/CountValidatorTest.php
vendored
Normal file
198
vendor/symfony/validator/Tests/Constraints/CountValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,198 @@
|
|||
<?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\Constraints\Count;
|
||||
use Symfony\Component\Validator\Constraints\CountValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
abstract class CountValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CountValidator();
|
||||
}
|
||||
|
||||
abstract protected function createCollection(array $content);
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Count(6));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsCountableType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Count(5));
|
||||
}
|
||||
|
||||
public function getThreeOrLessElements()
|
||||
{
|
||||
return array(
|
||||
array($this->createCollection(array(1))),
|
||||
array($this->createCollection(array(1, 2))),
|
||||
array($this->createCollection(array(1, 2, 3))),
|
||||
array($this->createCollection(array('a' => 1, 'b' => 2, 'c' => 3))),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFourElements()
|
||||
{
|
||||
return array(
|
||||
array($this->createCollection(array(1, 2, 3, 4))),
|
||||
array($this->createCollection(array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4))),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFiveOrMoreElements()
|
||||
{
|
||||
return array(
|
||||
array($this->createCollection(array(1, 2, 3, 4, 5))),
|
||||
array($this->createCollection(array(1, 2, 3, 4, 5, 6))),
|
||||
array($this->createCollection(array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5))),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getThreeOrLessElements
|
||||
*/
|
||||
public function testValidValuesMax($value)
|
||||
{
|
||||
$constraint = new Count(array('max' => 3));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFiveOrMoreElements
|
||||
*/
|
||||
public function testValidValuesMin($value)
|
||||
{
|
||||
$constraint = new Count(array('min' => 5));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFourElements
|
||||
*/
|
||||
public function testValidValuesExact($value)
|
||||
{
|
||||
$constraint = new Count(4);
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFiveOrMoreElements
|
||||
*/
|
||||
public function testTooManyValues($value)
|
||||
{
|
||||
$constraint = new Count(array(
|
||||
'max' => 4,
|
||||
'maxMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ count }}', \count($value))
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Count::TOO_MANY_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getThreeOrLessElements
|
||||
*/
|
||||
public function testTooFewValues($value)
|
||||
{
|
||||
$constraint = new Count(array(
|
||||
'min' => 4,
|
||||
'minMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ count }}', \count($value))
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Count::TOO_FEW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFiveOrMoreElements
|
||||
*/
|
||||
public function testTooManyValuesExact($value)
|
||||
{
|
||||
$constraint = new Count(array(
|
||||
'min' => 4,
|
||||
'max' => 4,
|
||||
'exactMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ count }}', \count($value))
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Count::TOO_MANY_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getThreeOrLessElements
|
||||
*/
|
||||
public function testTooFewValuesExact($value)
|
||||
{
|
||||
$constraint = new Count(array(
|
||||
'min' => 4,
|
||||
'max' => 4,
|
||||
'exactMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ count }}', \count($value))
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Count::TOO_FEW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testDefaultOption()
|
||||
{
|
||||
$constraint = new Count(5);
|
||||
|
||||
$this->assertEquals(5, $constraint->min);
|
||||
$this->assertEquals(5, $constraint->max);
|
||||
}
|
||||
}
|
105
vendor/symfony/validator/Tests/Constraints/CountryValidatorTest.php
vendored
Normal file
105
vendor/symfony/validator/Tests/Constraints/CountryValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?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\Intl\Util\IntlTestHelper;
|
||||
use Symfony\Component\Validator\Constraints\Country;
|
||||
use Symfony\Component\Validator\Constraints\CountryValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class CountryValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CountryValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Country());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Country());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Country());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidCountries
|
||||
*/
|
||||
public function testValidCountries($country)
|
||||
{
|
||||
$this->validator->validate($country, new Country());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidCountries()
|
||||
{
|
||||
return array(
|
||||
array('GB'),
|
||||
array('AT'),
|
||||
array('MY'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidCountries
|
||||
*/
|
||||
public function testInvalidCountries($country)
|
||||
{
|
||||
$constraint = new Country(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($country, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$country.'"')
|
||||
->setCode(Country::NO_SUCH_COUNTRY_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidCountries()
|
||||
{
|
||||
return array(
|
||||
array('foobar'),
|
||||
array('EN'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testValidateUsingCountrySpecificLocale()
|
||||
{
|
||||
// in order to test with "en_GB"
|
||||
IntlTestHelper::requireFullIntl($this, false);
|
||||
|
||||
\Locale::setDefault('en_GB');
|
||||
|
||||
$existingCountry = 'GB';
|
||||
|
||||
$this->validator->validate($existingCountry, new Country());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
}
|
107
vendor/symfony/validator/Tests/Constraints/CurrencyValidatorTest.php
vendored
Normal file
107
vendor/symfony/validator/Tests/Constraints/CurrencyValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?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\Intl\Util\IntlTestHelper;
|
||||
use Symfony\Component\Validator\Constraints\Currency;
|
||||
use Symfony\Component\Validator\Constraints\CurrencyValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class CurrencyValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CurrencyValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Currency());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Currency());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Currency());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidCurrencies
|
||||
*/
|
||||
public function testValidCurrencies($currency)
|
||||
{
|
||||
$this->validator->validate($currency, new Currency());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidCurrencies
|
||||
**/
|
||||
public function testValidCurrenciesWithCountrySpecificLocale($currency)
|
||||
{
|
||||
IntlTestHelper::requireFullIntl($this, false);
|
||||
|
||||
\Locale::setDefault('en_GB');
|
||||
|
||||
$this->validator->validate($currency, new Currency());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidCurrencies()
|
||||
{
|
||||
return array(
|
||||
array('EUR'),
|
||||
array('USD'),
|
||||
array('SIT'),
|
||||
array('AUD'),
|
||||
array('CAD'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidCurrencies
|
||||
*/
|
||||
public function testInvalidCurrencies($currency)
|
||||
{
|
||||
$constraint = new Currency(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($currency, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$currency.'"')
|
||||
->setCode(Currency::NO_SUCH_CURRENCY_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidCurrencies()
|
||||
{
|
||||
return array(
|
||||
array('EN'),
|
||||
array('foobar'),
|
||||
);
|
||||
}
|
||||
}
|
133
vendor/symfony/validator/Tests/Constraints/DateTimeValidatorTest.php
vendored
Normal file
133
vendor/symfony/validator/Tests/Constraints/DateTimeValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?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\Constraints\DateTime;
|
||||
use Symfony\Component\Validator\Constraints\DateTimeValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class DateTimeValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new DateTimeValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new DateTime());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new DateTime());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testDateTimeClassIsValid()
|
||||
{
|
||||
$this->validator->validate(new \DateTime(), new DateTime());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testDateTimeImmutableClassIsValid()
|
||||
{
|
||||
$this->validator->validate(new \DateTimeImmutable(), new DateTime());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new DateTime());
|
||||
}
|
||||
|
||||
public function testDateTimeWithDefaultFormat()
|
||||
{
|
||||
$this->validator->validate('1995-05-10 19:33:00', new DateTime());
|
||||
|
||||
$this->assertNoViolation();
|
||||
|
||||
$this->validator->validate('1995-03-24', new DateTime());
|
||||
|
||||
$this->buildViolation('This value is not a valid datetime.')
|
||||
->setParameter('{{ value }}', '"1995-03-24"')
|
||||
->setCode(DateTime::INVALID_FORMAT_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidDateTimes
|
||||
*/
|
||||
public function testValidDateTimes($format, $dateTime)
|
||||
{
|
||||
$constraint = new DateTime(array(
|
||||
'format' => $format,
|
||||
));
|
||||
|
||||
$this->validator->validate($dateTime, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidDateTimes()
|
||||
{
|
||||
return array(
|
||||
array('Y-m-d H:i:s e', '1995-03-24 00:00:00 UTC'),
|
||||
array('Y-m-d H:i:s', '2010-01-01 01:02:03'),
|
||||
array('Y/m/d H:i', '2010/01/01 01:02'),
|
||||
array('F d, Y', 'December 31, 1999'),
|
||||
array('d-m-Y', '10-05-1995'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidDateTimes
|
||||
*/
|
||||
public function testInvalidDateTimes($format, $dateTime, $code)
|
||||
{
|
||||
$constraint = new DateTime(array(
|
||||
'message' => 'myMessage',
|
||||
'format' => $format,
|
||||
));
|
||||
|
||||
$this->validator->validate($dateTime, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$dateTime.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidDateTimes()
|
||||
{
|
||||
return array(
|
||||
array('Y-m-d', 'foobar', DateTime::INVALID_FORMAT_ERROR),
|
||||
array('H:i', '00:00:00', DateTime::INVALID_FORMAT_ERROR),
|
||||
array('Y-m-d', '2010-01-01 00:00', DateTime::INVALID_FORMAT_ERROR),
|
||||
array('Y-m-d e', '2010-01-01 TCU', DateTime::INVALID_FORMAT_ERROR),
|
||||
array('Y-m-d H:i:s', '2010-13-01 00:00:00', DateTime::INVALID_DATE_ERROR),
|
||||
array('Y-m-d H:i:s', '2010-04-32 00:00:00', DateTime::INVALID_DATE_ERROR),
|
||||
array('Y-m-d H:i:s', '2010-02-29 00:00:00', DateTime::INVALID_DATE_ERROR),
|
||||
array('Y-m-d H:i:s', '2010-01-01 24:00:00', DateTime::INVALID_TIME_ERROR),
|
||||
array('Y-m-d H:i:s', '2010-01-01 00:60:00', DateTime::INVALID_TIME_ERROR),
|
||||
array('Y-m-d H:i:s', '2010-01-01 00:00:60', DateTime::INVALID_TIME_ERROR),
|
||||
);
|
||||
}
|
||||
}
|
108
vendor/symfony/validator/Tests/Constraints/DateValidatorTest.php
vendored
Normal file
108
vendor/symfony/validator/Tests/Constraints/DateValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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\Constraints\Date;
|
||||
use Symfony\Component\Validator\Constraints\DateValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class DateValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new DateValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Date());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Date());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testDateTimeClassIsValid()
|
||||
{
|
||||
$this->validator->validate(new \DateTime(), new Date());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testDateTimeImmutableClassIsValid()
|
||||
{
|
||||
$this->validator->validate(new \DateTimeImmutable(), new Date());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidDates
|
||||
*/
|
||||
public function testValidDates($date)
|
||||
{
|
||||
$this->validator->validate($date, new Date());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidDates()
|
||||
{
|
||||
return array(
|
||||
array('2010-01-01'),
|
||||
array('1955-12-12'),
|
||||
array('2030-05-31'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidDates
|
||||
*/
|
||||
public function testInvalidDates($date, $code)
|
||||
{
|
||||
$constraint = new Date(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($date, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$date.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidDates()
|
||||
{
|
||||
return array(
|
||||
array('foobar', Date::INVALID_FORMAT_ERROR),
|
||||
array('foobar 2010-13-01', Date::INVALID_FORMAT_ERROR),
|
||||
array('2010-13-01 foobar', Date::INVALID_FORMAT_ERROR),
|
||||
array('2010-13-01', Date::INVALID_DATE_ERROR),
|
||||
array('2010-04-32', Date::INVALID_DATE_ERROR),
|
||||
array('2010-02-29', Date::INVALID_DATE_ERROR),
|
||||
);
|
||||
}
|
||||
}
|
260
vendor/symfony/validator/Tests/Constraints/EmailValidatorTest.php
vendored
Normal file
260
vendor/symfony/validator/Tests/Constraints/EmailValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,260 @@
|
|||
<?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\Bridge\PhpUnit\DnsMock;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
use Symfony\Component\Validator\Constraints\EmailValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @group dns-sensitive
|
||||
*/
|
||||
class EmailValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new EmailValidator(false);
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Email());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Email());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Email());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidEmails
|
||||
*/
|
||||
public function testValidEmails($email)
|
||||
{
|
||||
$this->validator->validate($email, new Email());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidEmails()
|
||||
{
|
||||
return array(
|
||||
array('fabien@symfony.com'),
|
||||
array('example@example.co.uk'),
|
||||
array('fabien_potencier@example.fr'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidEmails
|
||||
*/
|
||||
public function testInvalidEmails($email)
|
||||
{
|
||||
$constraint = new Email(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($email, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$email.'"')
|
||||
->setCode(Email::INVALID_FORMAT_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidEmails()
|
||||
{
|
||||
return array(
|
||||
array('example'),
|
||||
array('example@'),
|
||||
array('example@localhost'),
|
||||
array('foo@example.com bar'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testStrict()
|
||||
{
|
||||
$constraint = new Email(array('strict' => true));
|
||||
|
||||
$this->validator->validate('example@localhost', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidEmailsForStrictChecks
|
||||
*/
|
||||
public function testStrictWithInvalidEmails($email)
|
||||
{
|
||||
$constraint = new Email(array(
|
||||
'message' => 'myMessage',
|
||||
'strict' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate($email, $constraint);
|
||||
|
||||
$this
|
||||
->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$email.'"')
|
||||
->setCode(Email::INVALID_FORMAT_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/egulias/EmailValidator/blob/1.2.8/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php
|
||||
*/
|
||||
public function getInvalidEmailsForStrictChecks()
|
||||
{
|
||||
return array(
|
||||
array('test@example.com test'),
|
||||
array('user name@example.com'),
|
||||
array('user name@example.com'),
|
||||
array('example.@example.co.uk'),
|
||||
array('example@example@example.co.uk'),
|
||||
array('(test_exampel@example.fr)'),
|
||||
array('example(example)example@example.co.uk'),
|
||||
array('.example@localhost'),
|
||||
array('ex\ample@localhost'),
|
||||
array('example@local\host'),
|
||||
array('example@localhost.'),
|
||||
array('user name@example.com'),
|
||||
array('username@ example . com'),
|
||||
array('example@(fake).com'),
|
||||
array('example@(fake.com'),
|
||||
array('username@example,com'),
|
||||
array('usern,ame@example.com'),
|
||||
array('user[na]me@example.com'),
|
||||
array('"""@iana.org'),
|
||||
array('"\"@iana.org'),
|
||||
array('"test"test@iana.org'),
|
||||
array('"test""test"@iana.org'),
|
||||
array('"test"."test"@iana.org'),
|
||||
array('"test".test@iana.org'),
|
||||
array('"test"'.\chr(0).'@iana.org'),
|
||||
array('"test\"@iana.org'),
|
||||
array(\chr(226).'@iana.org'),
|
||||
array('test@'.\chr(226).'.org'),
|
||||
array('\r\ntest@iana.org'),
|
||||
array('\r\n test@iana.org'),
|
||||
array('\r\n \r\ntest@iana.org'),
|
||||
array('\r\n \r\ntest@iana.org'),
|
||||
array('\r\n \r\n test@iana.org'),
|
||||
array('test@iana.org \r\n'),
|
||||
array('test@iana.org \r\n '),
|
||||
array('test@iana.org \r\n \r\n'),
|
||||
array('test@iana.org \r\n\r\n'),
|
||||
array('test@iana.org \r\n\r\n '),
|
||||
array('test@iana/icann.org'),
|
||||
array('test@foo;bar.com'),
|
||||
array('test;123@foobar.com'),
|
||||
array('test@example..com'),
|
||||
array('email.email@email."'),
|
||||
array('test@email>'),
|
||||
array('test@email<'),
|
||||
array('test@email{'),
|
||||
array(str_repeat('x', 254).'@example.com'), //email with warnings
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDnsChecks
|
||||
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
|
||||
*/
|
||||
public function testDnsChecks($type, $violation)
|
||||
{
|
||||
DnsMock::withMockedHosts(array('example.com' => array(array('type' => $violation ? false : $type))));
|
||||
|
||||
$constraint = new Email(array(
|
||||
'message' => 'myMessage',
|
||||
'MX' === $type ? 'checkMX' : 'checkHost' => true,
|
||||
));
|
||||
|
||||
$this->validator->validate('foo@example.com', $constraint);
|
||||
|
||||
if (!$violation) {
|
||||
$this->assertNoViolation();
|
||||
} else {
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"foo@example.com"')
|
||||
->setCode($violation)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
||||
|
||||
public function getDnsChecks()
|
||||
{
|
||||
return array(
|
||||
array('MX', false),
|
||||
array('MX', Email::MX_CHECK_FAILED_ERROR),
|
||||
array('A', false),
|
||||
array('A', Email::HOST_CHECK_FAILED_ERROR),
|
||||
array('AAAA', false),
|
||||
array('AAAA', Email::HOST_CHECK_FAILED_ERROR),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
|
||||
*/
|
||||
public function testHostnameIsProperlyParsed()
|
||||
{
|
||||
DnsMock::withMockedHosts(array('baz.com' => array(array('type' => 'MX'))));
|
||||
|
||||
$this->validator->validate(
|
||||
'"foo@bar"@baz.com',
|
||||
new Email(array('checkMX' => true))
|
||||
);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideCheckTypes
|
||||
*/
|
||||
public function testEmptyHostIsNotValid($checkType, $violation)
|
||||
{
|
||||
$this->validator->validate(
|
||||
'foo@bar.fr@',
|
||||
new Email(array(
|
||||
'message' => 'myMessage',
|
||||
$checkType => true,
|
||||
))
|
||||
);
|
||||
|
||||
$this
|
||||
->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"foo@bar.fr@"')
|
||||
->setCode($violation)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function provideCheckTypes()
|
||||
{
|
||||
return array(
|
||||
array('checkMX', Email::MX_CHECK_FAILED_ERROR),
|
||||
array('checkHost', Email::HOST_CHECK_FAILED_ERROR),
|
||||
);
|
||||
}
|
||||
}
|
78
vendor/symfony/validator/Tests/Constraints/EqualToValidatorTest.php
vendored
Normal file
78
vendor/symfony/validator/Tests/Constraints/EqualToValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?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\Constraints\EqualTo;
|
||||
use Symfony\Component\Validator\Constraints\EqualToValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new EqualToValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new EqualTo($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return EqualTo::NOT_EQUAL_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(3, 3),
|
||||
array(3, '3'),
|
||||
array('a', 'a'),
|
||||
array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')),
|
||||
array(new \DateTime('2000-01-01'), '2000-01-01'),
|
||||
array(new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'),
|
||||
array(new ComparisonTest_Class(5), new ComparisonTest_Class(5)),
|
||||
array(null, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(5),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, '1', 2, '2', 'integer'),
|
||||
array('22', '"22"', '333', '"333"', 'string'),
|
||||
array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2001-01-01 UTC'), 'Jan 1, 2001, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
);
|
||||
}
|
||||
}
|
273
vendor/symfony/validator/Tests/Constraints/ExpressionValidatorTest.php
vendored
Normal file
273
vendor/symfony/validator/Tests/Constraints/ExpressionValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,273 @@
|
|||
<?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\Constraints\Expression;
|
||||
use Symfony\Component\Validator\Constraints\ExpressionValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\ToString;
|
||||
|
||||
class ExpressionValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new ExpressionValidator();
|
||||
}
|
||||
|
||||
public function testExpressionIsEvaluatedWithNullValue()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'false',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'null')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testExpressionIsEvaluatedWithEmptyStringValue()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'false',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '""')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSucceedingExpressionAtObjectLevel()
|
||||
{
|
||||
$constraint = new Expression('this.data == 1');
|
||||
|
||||
$object = new Entity();
|
||||
$object->data = '1';
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFailingExpressionAtObjectLevel()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'this.data == 1',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$object = new Entity();
|
||||
$object->data = '2';
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'object')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSucceedingExpressionAtObjectLevelWithToString()
|
||||
{
|
||||
$constraint = new Expression('this.data == 1');
|
||||
|
||||
$object = new ToString();
|
||||
$object->data = '1';
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFailingExpressionAtObjectLevelWithToString()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'this.data == 1',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$object = new ToString();
|
||||
$object->data = '2';
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'toString')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSucceedingExpressionAtPropertyLevel()
|
||||
{
|
||||
$constraint = new Expression('value == this.data');
|
||||
|
||||
$object = new Entity();
|
||||
$object->data = '1';
|
||||
|
||||
$this->setRoot($object);
|
||||
$this->setPropertyPath('data');
|
||||
$this->setProperty($object, 'data');
|
||||
|
||||
$this->validator->validate('1', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFailingExpressionAtPropertyLevel()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'value == this.data',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$object = new Entity();
|
||||
$object->data = '1';
|
||||
|
||||
$this->setRoot($object);
|
||||
$this->setPropertyPath('data');
|
||||
$this->setProperty($object, 'data');
|
||||
|
||||
$this->validator->validate('2', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->atPath('data')
|
||||
->setParameter('{{ value }}', '"2"')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSucceedingExpressionAtNestedPropertyLevel()
|
||||
{
|
||||
$constraint = new Expression('value == this.data');
|
||||
|
||||
$object = new Entity();
|
||||
$object->data = '1';
|
||||
|
||||
$root = new Entity();
|
||||
$root->reference = $object;
|
||||
|
||||
$this->setRoot($root);
|
||||
$this->setPropertyPath('reference.data');
|
||||
$this->setProperty($object, 'data');
|
||||
|
||||
$this->validator->validate('1', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFailingExpressionAtNestedPropertyLevel()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'value == this.data',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$object = new Entity();
|
||||
$object->data = '1';
|
||||
|
||||
$root = new Entity();
|
||||
$root->reference = $object;
|
||||
|
||||
$this->setRoot($root);
|
||||
$this->setPropertyPath('reference.data');
|
||||
$this->setProperty($object, 'data');
|
||||
|
||||
$this->validator->validate('2', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->atPath('reference.data')
|
||||
->setParameter('{{ value }}', '"2"')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* When validatePropertyValue() is called with a class name
|
||||
* https://github.com/symfony/symfony/pull/11498.
|
||||
*/
|
||||
public function testSucceedingExpressionAtPropertyLevelWithoutRoot()
|
||||
{
|
||||
$constraint = new Expression('value == "1"');
|
||||
|
||||
$this->setRoot('1');
|
||||
$this->setPropertyPath('');
|
||||
$this->setProperty(null, 'property');
|
||||
|
||||
$this->validator->validate('1', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* When validatePropertyValue() is called with a class name
|
||||
* https://github.com/symfony/symfony/pull/11498.
|
||||
*/
|
||||
public function testFailingExpressionAtPropertyLevelWithoutRoot()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'value == "1"',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->setRoot('2');
|
||||
$this->setPropertyPath('');
|
||||
$this->setProperty(null, 'property');
|
||||
|
||||
$this->validator->validate('2', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->atPath('')
|
||||
->setParameter('{{ value }}', '"2"')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testExpressionLanguageUsage()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'false',
|
||||
));
|
||||
|
||||
$expressionLanguage = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionLanguage')->getMock();
|
||||
|
||||
$used = false;
|
||||
|
||||
$expressionLanguage->method('evaluate')
|
||||
->will($this->returnCallback(function () use (&$used) {
|
||||
$used = true;
|
||||
|
||||
return true;
|
||||
}));
|
||||
|
||||
$validator = new ExpressionValidator(null, $expressionLanguage);
|
||||
$validator->initialize($this->createContext());
|
||||
$validator->validate(null, $constraint);
|
||||
|
||||
$this->assertTrue($used, 'Failed asserting that custom ExpressionLanguage instance is used.');
|
||||
}
|
||||
}
|
139
vendor/symfony/validator/Tests/Constraints/FileTest.php
vendored
Normal file
139
vendor/symfony/validator/Tests/Constraints/FileTest.php
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?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 PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\File;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
|
||||
class FileTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideValidSizes
|
||||
*/
|
||||
public function testMaxSize($maxSize, $bytes, $binaryFormat)
|
||||
{
|
||||
$file = new File(array('maxSize' => $maxSize));
|
||||
|
||||
$this->assertSame($bytes, $file->maxSize);
|
||||
$this->assertSame($binaryFormat, $file->binaryFormat);
|
||||
$this->assertTrue($file->__isset('maxSize'));
|
||||
}
|
||||
|
||||
public function testMagicIsset()
|
||||
{
|
||||
$file = new File(array('maxSize' => 1));
|
||||
|
||||
$this->assertTrue($file->__isset('maxSize'));
|
||||
$this->assertTrue($file->__isset('groups'));
|
||||
$this->assertFalse($file->__isset('toto'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidSizes
|
||||
*/
|
||||
public function testMaxSizeCanBeSetAfterInitialization($maxSize, $bytes, $binaryFormat)
|
||||
{
|
||||
$file = new File();
|
||||
$file->maxSize = $maxSize;
|
||||
|
||||
$this->assertSame($bytes, $file->maxSize);
|
||||
$this->assertSame($binaryFormat, $file->binaryFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidSizes
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidValueForMaxSizeThrowsExceptionAfterInitialization($maxSize)
|
||||
{
|
||||
$file = new File(array('maxSize' => 1000));
|
||||
$file->maxSize = $maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidSizes
|
||||
*/
|
||||
public function testMaxSizeCannotBeSetToInvalidValueAfterInitialization($maxSize)
|
||||
{
|
||||
$file = new File(array('maxSize' => 1000));
|
||||
|
||||
try {
|
||||
$file->maxSize = $maxSize;
|
||||
} catch (ConstraintDefinitionException $e) {
|
||||
}
|
||||
|
||||
$this->assertSame(1000, $file->maxSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInValidSizes
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMaxSize($maxSize)
|
||||
{
|
||||
new File(array('maxSize' => $maxSize));
|
||||
}
|
||||
|
||||
public function provideValidSizes()
|
||||
{
|
||||
return array(
|
||||
array('500', 500, false),
|
||||
array(12300, 12300, false),
|
||||
array('1ki', 1024, true),
|
||||
array('1KI', 1024, true),
|
||||
array('2k', 2000, false),
|
||||
array('2K', 2000, false),
|
||||
array('1mi', 1048576, true),
|
||||
array('1MI', 1048576, true),
|
||||
array('3m', 3000000, false),
|
||||
array('3M', 3000000, false),
|
||||
);
|
||||
}
|
||||
|
||||
public function provideInvalidSizes()
|
||||
{
|
||||
return array(
|
||||
array('+100'),
|
||||
array('foo'),
|
||||
array('1Ko'),
|
||||
array('1kio'),
|
||||
array('1G'),
|
||||
array('1Gi'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFormats
|
||||
*/
|
||||
public function testBinaryFormat($maxSize, $guessedFormat, $binaryFormat)
|
||||
{
|
||||
$file = new File(array('maxSize' => $maxSize, 'binaryFormat' => $guessedFormat));
|
||||
|
||||
$this->assertSame($binaryFormat, $file->binaryFormat);
|
||||
}
|
||||
|
||||
public function provideFormats()
|
||||
{
|
||||
return array(
|
||||
array(100, null, false),
|
||||
array(100, true, true),
|
||||
array(100, false, false),
|
||||
array('100K', null, false),
|
||||
array('100K', true, true),
|
||||
array('100K', false, false),
|
||||
array('100Ki', null, true),
|
||||
array('100Ki', true, true),
|
||||
array('100Ki', false, false),
|
||||
);
|
||||
}
|
||||
}
|
22
vendor/symfony/validator/Tests/Constraints/FileValidatorObjectTest.php
vendored
Normal file
22
vendor/symfony/validator/Tests/Constraints/FileValidatorObjectTest.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?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\HttpFoundation\File\File;
|
||||
|
||||
class FileValidatorObjectTest extends FileValidatorTest
|
||||
{
|
||||
protected function getFile($filename)
|
||||
{
|
||||
return new File($filename);
|
||||
}
|
||||
}
|
36
vendor/symfony/validator/Tests/Constraints/FileValidatorPathTest.php
vendored
Normal file
36
vendor/symfony/validator/Tests/Constraints/FileValidatorPathTest.php
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?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\Constraints\File;
|
||||
|
||||
class FileValidatorPathTest extends FileValidatorTest
|
||||
{
|
||||
protected function getFile($filename)
|
||||
{
|
||||
return $filename;
|
||||
}
|
||||
|
||||
public function testFileNotFound()
|
||||
{
|
||||
$constraint = new File(array(
|
||||
'notFoundMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('foobar', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ file }}', '"foobar"')
|
||||
->setCode(File::NOT_FOUND_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
478
vendor/symfony/validator/Tests/Constraints/FileValidatorTest.php
vendored
Normal file
478
vendor/symfony/validator/Tests/Constraints/FileValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,478 @@
|
|||
<?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\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\Validator\Constraints\File;
|
||||
use Symfony\Component\Validator\Constraints\FileValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
abstract class FileValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected $path;
|
||||
|
||||
protected $file;
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new FileValidator();
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->path = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'FileValidatorTest';
|
||||
$this->file = fopen($this->path, 'w');
|
||||
fwrite($this->file, ' ', 1);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
if (\is_resource($this->file)) {
|
||||
fclose($this->file);
|
||||
}
|
||||
|
||||
if (file_exists($this->path)) {
|
||||
unlink($this->path);
|
||||
}
|
||||
|
||||
$this->path = null;
|
||||
$this->file = null;
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new File());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new File());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleTypeOrFile()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new File());
|
||||
}
|
||||
|
||||
public function testValidFile()
|
||||
{
|
||||
$this->validator->validate($this->path, new File());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidUploadedfile()
|
||||
{
|
||||
$file = new UploadedFile($this->path, 'originalName', null, null, null, true);
|
||||
$this->validator->validate($file, new File());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function provideMaxSizeExceededTests()
|
||||
{
|
||||
// We have various interesting limit - size combinations to test.
|
||||
// Assume a limit of 1000 bytes (1 kB). Then the following table
|
||||
// lists the violation messages for different file sizes:
|
||||
// -----------+--------------------------------------------------------
|
||||
// Size | Violation Message
|
||||
// -----------+--------------------------------------------------------
|
||||
// 1000 bytes | No violation
|
||||
// 1001 bytes | "Size of 1001 bytes exceeded limit of 1000 bytes"
|
||||
// 1004 bytes | "Size of 1004 bytes exceeded limit of 1000 bytes"
|
||||
// | NOT: "Size of 1 kB exceeded limit of 1 kB"
|
||||
// 1005 bytes | "Size of 1.01 kB exceeded limit of 1 kB"
|
||||
// -----------+--------------------------------------------------------
|
||||
|
||||
// As you see, we have two interesting borders:
|
||||
|
||||
// 1000/1001 - The border as of which a violation occurs
|
||||
// 1004/1005 - The border as of which the message can be rounded to kB
|
||||
|
||||
// Analogous for kB/MB.
|
||||
|
||||
// Prior to Symfony 2.5, violation messages are always displayed in the
|
||||
// same unit used to specify the limit.
|
||||
|
||||
// As of Symfony 2.5, the above logic is implemented.
|
||||
return array(
|
||||
// limit in bytes
|
||||
array(1001, 1000, '1001', '1000', 'bytes'),
|
||||
array(1004, 1000, '1004', '1000', 'bytes'),
|
||||
array(1005, 1000, '1.01', '1', 'kB'),
|
||||
|
||||
array(1000001, 1000000, '1000001', '1000000', 'bytes'),
|
||||
array(1004999, 1000000, '1005', '1000', 'kB'),
|
||||
array(1005000, 1000000, '1.01', '1', 'MB'),
|
||||
|
||||
// limit in kB
|
||||
array(1001, '1k', '1001', '1000', 'bytes'),
|
||||
array(1004, '1k', '1004', '1000', 'bytes'),
|
||||
array(1005, '1k', '1.01', '1', 'kB'),
|
||||
|
||||
array(1000001, '1000k', '1000001', '1000000', 'bytes'),
|
||||
array(1004999, '1000k', '1005', '1000', 'kB'),
|
||||
array(1005000, '1000k', '1.01', '1', 'MB'),
|
||||
|
||||
// limit in MB
|
||||
array(1000001, '1M', '1000001', '1000000', 'bytes'),
|
||||
array(1004999, '1M', '1005', '1000', 'kB'),
|
||||
array(1005000, '1M', '1.01', '1', 'MB'),
|
||||
|
||||
// limit in KiB
|
||||
array(1025, '1Ki', '1025', '1024', 'bytes'),
|
||||
array(1029, '1Ki', '1029', '1024', 'bytes'),
|
||||
array(1030, '1Ki', '1.01', '1', 'KiB'),
|
||||
|
||||
array(1048577, '1024Ki', '1048577', '1048576', 'bytes'),
|
||||
array(1053818, '1024Ki', '1029.12', '1024', 'KiB'),
|
||||
array(1053819, '1024Ki', '1.01', '1', 'MiB'),
|
||||
|
||||
// limit in MiB
|
||||
array(1048577, '1Mi', '1048577', '1048576', 'bytes'),
|
||||
array(1053818, '1Mi', '1029.12', '1024', 'KiB'),
|
||||
array(1053819, '1Mi', '1.01', '1', 'MiB'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMaxSizeExceededTests
|
||||
*/
|
||||
public function testMaxSizeExceeded($bytesWritten, $limit, $sizeAsString, $limitAsString, $suffix)
|
||||
{
|
||||
fseek($this->file, $bytesWritten - 1, SEEK_SET);
|
||||
fwrite($this->file, '0');
|
||||
fclose($this->file);
|
||||
|
||||
$constraint = new File(array(
|
||||
'maxSize' => $limit,
|
||||
'maxSizeMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ limit }}', $limitAsString)
|
||||
->setParameter('{{ size }}', $sizeAsString)
|
||||
->setParameter('{{ suffix }}', $suffix)
|
||||
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||
->setCode(File::TOO_LARGE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function provideMaxSizeNotExceededTests()
|
||||
{
|
||||
return array(
|
||||
// limit in bytes
|
||||
array(1000, 1000),
|
||||
array(1000000, 1000000),
|
||||
|
||||
// limit in kB
|
||||
array(1000, '1k'),
|
||||
array(1000000, '1000k'),
|
||||
|
||||
// limit in MB
|
||||
array(1000000, '1M'),
|
||||
|
||||
// limit in KiB
|
||||
array(1024, '1Ki'),
|
||||
array(1048576, '1024Ki'),
|
||||
|
||||
// limit in MiB
|
||||
array(1048576, '1Mi'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMaxSizeNotExceededTests
|
||||
*/
|
||||
public function testMaxSizeNotExceeded($bytesWritten, $limit)
|
||||
{
|
||||
fseek($this->file, $bytesWritten - 1, SEEK_SET);
|
||||
fwrite($this->file, '0');
|
||||
fclose($this->file);
|
||||
|
||||
$constraint = new File(array(
|
||||
'maxSize' => $limit,
|
||||
'maxSizeMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMaxSize()
|
||||
{
|
||||
$constraint = new File(array(
|
||||
'maxSize' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->path, $constraint);
|
||||
}
|
||||
|
||||
public function provideBinaryFormatTests()
|
||||
{
|
||||
return array(
|
||||
array(11, 10, null, '11', '10', 'bytes'),
|
||||
array(11, 10, true, '11', '10', 'bytes'),
|
||||
array(11, 10, false, '11', '10', 'bytes'),
|
||||
|
||||
// round(size) == 1.01kB, limit == 1kB
|
||||
array(ceil(1000 * 1.01), 1000, null, '1.01', '1', 'kB'),
|
||||
array(ceil(1000 * 1.01), '1k', null, '1.01', '1', 'kB'),
|
||||
array(ceil(1024 * 1.01), '1Ki', null, '1.01', '1', 'KiB'),
|
||||
|
||||
array(ceil(1024 * 1.01), 1024, true, '1.01', '1', 'KiB'),
|
||||
array(ceil(1024 * 1.01 * 1000), '1024k', true, '1010', '1000', 'KiB'),
|
||||
array(ceil(1024 * 1.01), '1Ki', true, '1.01', '1', 'KiB'),
|
||||
|
||||
array(ceil(1000 * 1.01), 1000, false, '1.01', '1', 'kB'),
|
||||
array(ceil(1000 * 1.01), '1k', false, '1.01', '1', 'kB'),
|
||||
array(ceil(1024 * 1.01 * 10), '10Ki', false, '10.34', '10.24', 'kB'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideBinaryFormatTests
|
||||
*/
|
||||
public function testBinaryFormat($bytesWritten, $limit, $binaryFormat, $sizeAsString, $limitAsString, $suffix)
|
||||
{
|
||||
fseek($this->file, $bytesWritten - 1, SEEK_SET);
|
||||
fwrite($this->file, '0');
|
||||
fclose($this->file);
|
||||
|
||||
$constraint = new File(array(
|
||||
'maxSize' => $limit,
|
||||
'binaryFormat' => $binaryFormat,
|
||||
'maxSizeMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ limit }}', $limitAsString)
|
||||
->setParameter('{{ size }}', $sizeAsString)
|
||||
->setParameter('{{ suffix }}', $suffix)
|
||||
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||
->setCode(File::TOO_LARGE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidMimeType()
|
||||
{
|
||||
$file = $this
|
||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||
->getMock();
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getPathname')
|
||||
->will($this->returnValue($this->path));
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getMimeType')
|
||||
->will($this->returnValue('image/jpg'));
|
||||
|
||||
$constraint = new File(array(
|
||||
'mimeTypes' => array('image/png', 'image/jpg'),
|
||||
));
|
||||
|
||||
$this->validator->validate($file, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidWildcardMimeType()
|
||||
{
|
||||
$file = $this
|
||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||
->getMock();
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getPathname')
|
||||
->will($this->returnValue($this->path));
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getMimeType')
|
||||
->will($this->returnValue('image/jpg'));
|
||||
|
||||
$constraint = new File(array(
|
||||
'mimeTypes' => array('image/*'),
|
||||
));
|
||||
|
||||
$this->validator->validate($file, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testInvalidMimeType()
|
||||
{
|
||||
$file = $this
|
||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||
->getMock();
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getPathname')
|
||||
->will($this->returnValue($this->path));
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getMimeType')
|
||||
->will($this->returnValue('application/pdf'));
|
||||
|
||||
$constraint = new File(array(
|
||||
'mimeTypes' => array('image/png', 'image/jpg'),
|
||||
'mimeTypesMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($file, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ type }}', '"application/pdf"')
|
||||
->setParameter('{{ types }}', '"image/png", "image/jpg"')
|
||||
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||
->setCode(File::INVALID_MIME_TYPE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testInvalidWildcardMimeType()
|
||||
{
|
||||
$file = $this
|
||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||
->getMock();
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getPathname')
|
||||
->will($this->returnValue($this->path));
|
||||
$file
|
||||
->expects($this->once())
|
||||
->method('getMimeType')
|
||||
->will($this->returnValue('application/pdf'));
|
||||
|
||||
$constraint = new File(array(
|
||||
'mimeTypes' => array('image/*', 'image/jpg'),
|
||||
'mimeTypesMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($file, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ type }}', '"application/pdf"')
|
||||
->setParameter('{{ types }}', '"image/*", "image/jpg"')
|
||||
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||
->setCode(File::INVALID_MIME_TYPE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testDisallowEmpty()
|
||||
{
|
||||
ftruncate($this->file, 0);
|
||||
|
||||
$constraint = new File(array(
|
||||
'disallowEmptyMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||
->setCode(File::EMPTY_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider uploadedFileErrorProvider
|
||||
*/
|
||||
public function testUploadedFileError($error, $message, array $params = array(), $maxSize = null)
|
||||
{
|
||||
$file = new UploadedFile('/path/to/file', 'originalName', 'mime', 0, $error);
|
||||
|
||||
$constraint = new File(array(
|
||||
$message => 'myMessage',
|
||||
'maxSize' => $maxSize,
|
||||
));
|
||||
|
||||
$this->validator->validate($file, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameters($params)
|
||||
->setCode($error)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function uploadedFileErrorProvider()
|
||||
{
|
||||
$tests = array(
|
||||
array(UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'),
|
||||
array(UPLOAD_ERR_PARTIAL, 'uploadPartialErrorMessage'),
|
||||
array(UPLOAD_ERR_NO_FILE, 'uploadNoFileErrorMessage'),
|
||||
array(UPLOAD_ERR_NO_TMP_DIR, 'uploadNoTmpDirErrorMessage'),
|
||||
array(UPLOAD_ERR_CANT_WRITE, 'uploadCantWriteErrorMessage'),
|
||||
array(UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'),
|
||||
);
|
||||
|
||||
if (class_exists('Symfony\Component\HttpFoundation\File\UploadedFile')) {
|
||||
// when no maxSize is specified on constraint, it should use the ini value
|
||||
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
|
||||
'{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576,
|
||||
'{{ suffix }}' => 'MiB',
|
||||
));
|
||||
|
||||
// it should use the smaller limitation (maxSize option in this case)
|
||||
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
|
||||
'{{ limit }}' => 1,
|
||||
'{{ suffix }}' => 'bytes',
|
||||
), '1');
|
||||
|
||||
// access FileValidator::factorizeSizes() private method to format max file size
|
||||
$reflection = new \ReflectionClass(\get_class(new FileValidator()));
|
||||
$method = $reflection->getMethod('factorizeSizes');
|
||||
$method->setAccessible(true);
|
||||
list($sizeAsString, $limit, $suffix) = $method->invokeArgs(new FileValidator(), array(0, UploadedFile::getMaxFilesize(), false));
|
||||
|
||||
// it correctly parses the maxSize option and not only uses simple string comparison
|
||||
// 1000M should be bigger than the ini value
|
||||
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
|
||||
'{{ limit }}' => $limit,
|
||||
'{{ suffix }}' => $suffix,
|
||||
), '1000M');
|
||||
|
||||
// it correctly parses the maxSize option and not only uses simple string comparison
|
||||
// 1000M should be bigger than the ini value
|
||||
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
|
||||
'{{ limit }}' => '0.1',
|
||||
'{{ suffix }}' => 'MB',
|
||||
), '100K');
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
abstract protected function getFile($filename);
|
||||
}
|
30
vendor/symfony/validator/Tests/Constraints/Fixtures/ChildA.php
vendored
Normal file
30
vendor/symfony/validator/Tests/Constraints/Fixtures/ChildA.php
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?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\Fixtures;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class ChildA
|
||||
{
|
||||
/**
|
||||
* @Assert\Valid
|
||||
* @Assert\NotNull
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* @var ChildB
|
||||
* @Assert\Valid
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
public $childB;
|
||||
}
|
29
vendor/symfony/validator/Tests/Constraints/Fixtures/ChildB.php
vendored
Normal file
29
vendor/symfony/validator/Tests/Constraints/Fixtures/ChildB.php
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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\Fixtures;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class ChildB
|
||||
{
|
||||
/**
|
||||
* @Assert\Valid
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* @var ChildA
|
||||
* @Assert\Valid
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
public $childA;
|
||||
}
|
0
vendor/symfony/validator/Tests/Constraints/Fixtures/foo
vendored
Normal file
0
vendor/symfony/validator/Tests/Constraints/Fixtures/foo
vendored
Normal file
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test.gif
vendored
Normal file
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 801 B |
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test_4by3.gif
vendored
Normal file
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test_4by3.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 B |
86
vendor/symfony/validator/Tests/Constraints/Fixtures/test_corrupted.gif
vendored
Normal file
86
vendor/symfony/validator/Tests/Constraints/Fixtures/test_corrupted.gif
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
GIF89ad d ÷ Ro«(DHÏÓÔm/t8f†j<E280A0>’üÿÿ2W[#V–¥nkwLPQ&9C’³É!49†)u)3²êꮳ´15%ITEtx8Wc65jCiw
|
||||
e§«¦±Ôtœ¼KFCE‡UŠ˜;djè÷ø2FXx·¹–ÆÆˆº¼"'7to‚E2k±,<2C>ÑÜîÏLºèêêW‡ˆ8$G¾ËèL…Šg8€fs¯Hx‡e˜¥36G†—)5:GzHY–Ú÷÷7)XU”›ËæëE&V8B©ÈÖ#$Z£©ˆ“º‹ÄǨÖ×%#EoH˜FYažÀÀGceÃ3¡4juv¥«gVu(RW49Ugª²)*x©¹T+ek³¶He™7A7JdI+aB9F7s”0„†–—SJ–¶R¶S0jØèé
|
||||
(Ug"*óþüh‚½6VuU[¦W{–W7vFDdDw”¬<E2809D>ÌC K—S³iS¥—˜š(6X»vÆEj‰AQˆ¶ØÛw–µ VJj¦ËÎN€|"*æìöiVBLaЦÙìò‘œÄóôôXxz™Ö×14IQz‡K”›(Kb777<37>pµ7s}<7D>y‰W"W"*€‡ˆÉöõC0Hh›´RD<52>Ei[#"%3#;¼ÇÆV£žE;VœÈѸe¹&$Xj˜™§ª!$v°®,[s‡„“)ah/,gri#^”½» rš¦PT<50>…«»WWd
ô÷úX‘‹.GMEXt„Jž³ÊÞIvm
_ers޳’‹—()
*)Og <67>BA}Š¢¤}ÃÈKM‘VefÉíðXZo7^^m¶¯p‹¸áâ$?>íñðQgŠ‚µ±=‚ˆ¸=§ Ã`¼0,¡œ££ÐÏÝßßÈáá0*œ®°£Fœû÷üöûúòïô
|
||||
$1PR¶½àH<C3A0><48>0/,1[[ˆJBO
($($-.-RM<>ÌÐ+NO_/o:2y!d¿¾Ãðëïóóï¤áá¡¢¢ ÿÿÿ!ÿNETSCAPE2.0 !ù
|
||||
ÿ , d d ¡ û H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç<C2A3> CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ
|
||||
J´¨Ñ£H“*]Ê´©Ó§P£J<C2A3>JµªÕ«X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶۷pãÊ<C3A3>K·®Ý»xóêÝË·¯ß¿€L¸°áÈ+^ÌXp@ !ù
|
||||
ÿ , d d ÿ 7H° Áƒ*\Ȱ¡C#JœH±¢Å‹3jÜȱ£Ç<C2A3> CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ
|
||||
J´¨Ñ£H“*]Ê´©Ó§P£J<C2A3>JµªÕ«X³jÝʵ«×¯`ÊK¶lÆe´š¶©›Yw’$¤ƒP<C692>n*YjÛê7 †d€1<E282AC>H„â®;!¿{ÕU<C395>žˆŠd¼˜|ÇÖàˆseìøE0 ]-ÄFƒ`Ì™·.hœ‹–ëÏzD‹&}oꬾ:Þ-ÛÕîµo_åæ@ÄkÞ¾“auÚ½T%<1D><>¼ºr6jÛ~^uµqP¬‡ñ¯!€óáÅi…_?¾€{òæÎC<C38E>š À…`¥Ø¿oZÑ–$ lgU}5à§ß û%XC|†q]q†— k!PÈÜ`:øà}ù%‡`… †x òuWÁw~8ÙŠ"NÑ †SIW`Š*²Ys¦ÙƒÉxÖß{6Vf^ŽÂmhã‘”‘Hd‘BÆÆ“G§<>ŽLVU…_¶<™ˆ"0¸äŽÃýá h p
ùå|X1„_d^ö"Œ]¡—\ÌY%_Tîù›ný)è „j衈&ªè¢Œ6êè£<C3A8>F*餔Vj饘fªé¦œvêé§ †úШ !ù
|
||||
ÿ , ! & % ÿ ÿ H°`·
*\Èa·‡"J„ذ¢@ˆã2.ÐÈq¢Eƒ5’I’dÇ<64>%ê*©®BË—&3¢tˆ€¥ ›8qºŒ‰2âH—9¥ªSÝJ™}¶Äi¦)ª§P‰î<Êp<C38A>Ò 7¡>Ùúˆ«ª¨7<C2A8>êB
|
||||
2ãR¡_»F[˶ëצaG’øp%V´<56>Ø¢ÛË·íÛ¸=Ò¬<C392>U-_‹+ÆÁö©Abç"´káéZÅ<5A>2kÎÜ×íãÈ)ÍV~rs‘Ó¨O3^»õ³¯±•2R•×ôf¸q/öä5‚Ø”IÛ¾<C39B>[÷jp%Àž¨‹°™ÚÄS/’ø
ï©Ì<C2A9>_žÎ}zuäŒ KÙZ^+íÄÿJ©§Ò½øw5á!(ïHаðÓÐÖ·7μøÀÕ7Zbûq‡X¦Ä7R¢¡]tÝXƒØ¨Ž Ïía„ï)Hžl÷mè‚É}XÞ€ŠHÝq º&Sv†¨b$º8—ljauÖµXF YhÞƒÃñx<C3B1>‰t5è u«ÖY‹½-(X’ܜŕ^~ùè vSRéË]–ååÖVŽý(YYõ£Vešy¦Bu¥y×ctºùæB*<2A>÷V.q äLŹK1ý hhôýd—‡EA2 !ù
|
||||
ÿ , / - ÿ ÿ H°àÀn[)\h°¡Ã‡Ž›H±¢Eˆ#þ*ƒ c] Cz¼˜cB‘’RJPÉR$Ã’=’bY¡¦Í•8gŽ„YP"Í @ƒ
|
||||
½™r'Ï
|
||||
Cª»9´)Q<>$!&U)T<>Õ«X<C2AB>í˜Ð丙K«bµ@¶lÖ [£ö”Ô,£·pãšÕªöàD_aÝÊÝ+whÚ®kÁŽ5×°a¾uкŒ™7®©Ã<C2A9>#K><·&TÀH7JZòdÏŸá:P•ãÒ·ªž¤VÍ:´kѤ/šbAÄ£Û8rçþw{õkÊdcÛ] ®v
t‹Š(W¾hQ´Þ¿<C39E>_]¹)© ¦¢)XN¥»wçoˆÿ÷ýú,H†I=Ú®¬½{÷EÀ<45><C380>uŽ7\W•‹ÿÿ v'ß|¿M·Ôù"ÈE¼ €
|
||||
äF`<60>Á˜ ‹”p+žà` þÅÞ„ÖwßùI`JƒLtØá‡"Ž(Þ4Öˆ‡&þq^;U@ G˜ÐbB~¢„wda£<61>8æÈU<C388>ªä<>E‚è`„2.ɤ“>E¹!•ˆ¤’Zcf“îhÝŠº¨¡˜Y–y¦‰%vbŠêqð¦•pÆ)§hÚ÷W7º`ÇÞƒ|þƒ%™Œþ9š Oâ‰CƒF†¸h’<68>–¹E…ƒ"´ß¤•ƈi¦K‚`ª<>wÚUœ z'à¥óý—yª@éè~ªV žvÛŧ蘱ʊêŽÓF›)ª½¡t$þ™Á°kì±È’Hž7–*̳оDÐTÔÒ'Y¶t2Òíè:îU ÑWg¥+H<>µ[žU9q$í¼ô¶åؽ±ÕÅU<>ýÛ
|
||||
'z[ÒTTq¦Wš<57>•‚?i•ðF¯•àO<C3A0>b–±ÆG+ðÇ1Y„¢Ç% !ù
|
||||
ÿ , 9 8 ÿ ÿ H° Á<C2A0>›Ê(\Èð ÇvcèNVE‹/6ŒÈ"ÅT CŠL@RãÆŽ(?ŠL²¥Ë‘'S:Té˜Í›8_f”éqáÊœ=‚
|
||||
Í 3¦Ì‰ÍÀtéP›EyLZÓ©Õ¦O[š”Jµ*Ö¯`±ˆ4¥O¯aÓ‚KÖ,I´juxFW-Ô<>F"}{3®Ü¿€ç
|
||||
{wgO‹pëVbñÚÂyîÙÐõëâÆ˜33v|/噕™^ÆCz´fÎ<66>?ô§d߀KËÖ1»6ÝÓX=¤ŒX(lÒ;‚n›¶qÍ*æ-¹{/ËßÀ³HŸNøéëus–ÌZÖsèÓEÿO½|ñâ„™œÜ{Ktòðã›?<3F>[»;½Ÿã™ž¦ùòUG_vu¤†Ð?( ›tþ
ò€
|
||||
‡]}þ3‘$ ÒÆÆ –,áƒBHž„6f_C$9à
Xáb‡0†(bÅX7¡‰'Z˜_ j àÁL˜pÄ %¼âŒk<C592>x#<23>,Y$™w<10>À†°°bÂ5Xi¤ƒH¾Ü’8¦ÖJжR¥<52>XfùOŒ\Îhã’6yß… j`C C^‰ÄžZ¶è_—%†)§ŽdZ‚§ž{öÑg‡2¨ä%ž¸WvZdš|ÂÂ& ¯€©œ<C2A9>Qjæ ˆfº)§a@ª*…rî•@”S’ÿÚǬŠjÊ(/<2F>F¨Ä»®ÊjI‘P©¬BÉf®ðÁë²½úšYœÀr÷êwp䢧BÈì®Üb“•<>!µ¶h ç*pd—Û6‹\SºéØ]n˜ÆÈÊ×n·ï~;'BÝ%1…ÁÍÈn»ÎÊU!wì)H°Á޾²¯»‚¶ºZÀ*îÄ4N¬DÂðF‹<1F>ôjÌ1usËï³þ–5òÜHPòÆn~™êÊÈ-|qkðhr„ÔÕ˜ð¯m¦†3t bÅÛSBGËL‚´ ¨q’ªö40'ÝÕõ1• g ¹ÅWÉÇ¥öm
|
||||
·™D„¶Tà×k6·˜\Úµ×sÃK&jþêµÖ\<5C>%õkô>¦ÓVyÜU‚@Õ*Y„7.ïã<C3AF>g.'°”WnùåIEÍùèá~Z¸0§®úÛ¦ŸŽ:ëwTzì¦;G !ù
|
||||
ÿ , J < ÿ ÿ H° Áƒý)\Ȱ!‡#J4ذ¢Å‰3J´È±£Æ<C2A3>;ŠB²ä¦“ Syò—IY0cÊ4©²&Ë’gdæÜÉs&J›oêÌ©%‡Ñ£H{º£ ô¡P¤0ŠF•:•êQŸMWŽŒiHT.^Ê
{uéϬÿ¶r
|
||||
öJÛ·pÉÝÉ´éV¨cãŽqË7î\ºgUvL ¯Þ¾‡÷¾<C3B7>
|
||||
8ðG‹"§2
|
||||
¬G˜#ÞœXncÁ<63>%¡HRù²—Ó¨5wæ¶ã˜Ž1V$,<2C>tiÔÂÚèÞzuo×ë†l‰€T•ã·qç¾Ä¼yêÞÐU¿†ýø¤."Æ+©ÃÝôòæaœóÿŽNÞ3õáÅÿ×Þ]ˆïáÁ‹/Ϻõtá7èO/AÝvAlñ^1ñÉgàx™ùf_peì§Õ~
JæŸí<>°Ã+fX xÌ=GŸ_æá8$fÇ€jàq¡†k°x ‡JWÖ’Xb'Öb†{+®ñ
-¹á|1rvE¸d#7¾àø#ª¸ 4TY¥<59>CvcŒÀÍXq2™£ PJIå<49>i¤ $–Yidˆ_¾´Þ“Rl‘"•Vª©&›Dº)£Qfi¥Þ˜dZp'žz&ÊgŸ~ÚwÞ—ƒ` Ðyhž‰¦¹¨–<C2A8>.È ƒiEJéRb)¢™îé"£äÕóÛ§•ÿH!0’J꩘¦ºf›~gZK%âÆÂŽzk¡—êª*¯½–ÕgKéÁ°Ä[ª©Pf<50>ª²›nÙ¬b°[F*ÄÒjm¡†â±-šzþÓí·®¾ú©ƒãÒZ¬•’™l»í¾; ¼ñò.AÐV«¤“&¬î¶‰º»é¿G\ß‚ÐLR“t껯@ý®z‰Äƒ,/ øÅ*aÂ(_x&»š¾ëEÈ0‹î³©<ºÒu„¦¨rÃ.G³Ì,(Æ–š9PÏãýì󟋈ó‰Zèq–k¦4ÐÃ[œ7>)5<>SsšôÕ2ÓlsD]{-%Õ¬îE¶ÄæŠÞ?µUÈvÕ*ööfónÆí4Ýu{7à<37> ï}߈…9Yrƒ‹<C692>`ሙmV7 &>îâ–)ç‚n3µ¸ÕYwe™wúíá~£·é@ ÌyÜJ¦.å«kòÕ믓<yå@ÕNUë¸<C3AB>¬{„ ÛE{a¿¿˜ä<CB9C>Êž’B:%<25>{U}7ˆ’8±žWgÔ7}ýÍkIïi—Õüù÷}Wä'eþç¼£Ïu´£»oÿð
N¿ü"f<>üý>‰ÿB§¸™0I´Éˆv÷’vЋv Ì
|
||||
˜Á:# !ù
|
||||
ÿ , [ ; ÿ ÿ H° Áƒú[Ȱa·2ÿm˜¨°¢Å‹:ÜñaÇMCfIÒ"Ç“BB¦¨RbÉ—/QNT™²¦¬•.mz„ÉӤǟ3iž¹9”hÑ£5<C2A3>ö\:(M¡Õ<C2A1>ž¹AUêÍ–La‚|êΨר`«Š‹TdV’[;zM°`j*·9âÊ%«¥®]<5D>`¯&=‹‘ãÚ·€çÚ¥:¸páyõâä«0èßÀI"Ã0<™²å¹Š¥eLЯ$¶Ÿÿˆ–\¹‡i ¨ã”¾l¸ìÊÍœ<C38D>†
™ôéÔªs³¾‹93EÆžg×v›‹ñã¸Wï*©fØ1¹ê>œxqäÉu/gîúHém©Kÿ€€Xyë×±gßÎÝ·Vð´Ï×q0?QzøÕ¯g_Õ}IÇ…&_}$ÔwŸ~ûñ×Ýo}9¥V|óé@ fà……ùe¨a‚
|
||||
ú—‘_ÅG<C385>ÜQ"‰jT(Ì…¶ˆ`‡Î™ÕˆáAâ!ä¨H
&€‡@®è¢‹ÚÁØ•ŒÉ” ôhT” %>èèã<C3A8>Bù"íauQZAIÐä“Qž0%T²ÁÆXf©%‡F"9cŒbŠP™¥ÀbæžiðÊ úæ–qÊyЃ:`Î8B©çž|þ³æ+—¸9h‘…zg¢‰b <62>“6@aEž<45>òÉ‹¤”VÊ⥘nל‡›:ÿ"“æ$cÌ.l¸¢k©¬˜Ê‹ŸÅ¨º*‘ºº K€)
|
||||
Íd§"„**¯{žJ›–[¬±¾ÉÚmMŠÖR«“jîJ-,Vxð+¶Ã²Êe—\I´l3âþól¹Óžû+°Ùjû.¼†"b²)Ñ:.£ƒ˜«ïµÅ´ë¯r–µzìœj1+®ä&¬°©üjè0¡Kë¡—±€Á7ºq)–„бLJ¼mb7& ÊM€êüF›0§ÌºMühäÑs°Žjš$†Aƒ¼<ÿD‚©Ñ2„4(v=Eu€u†SËóAÙb‘3rƒŽ±Ä„ô5ÌpšmµÝgÏŒõw…ÿ7y€ØnÙwã÷Úhía²Éâ
(vÌ….¹äý!žøâ~è8ä‘>yÞ /ÖSߌknÛ<6E>uNyå{ÿGzãè
1è´×NsŒ|)» ñ<>>3ч¿Š;pZcÞûìÀv5ëï{æ‚%/ýí–<C3AD>þ:ôÑO™6Ôkêüõ_eßÚøp ßzlJ%þúi—oUõgÑx¤,a¹OYï¯Õ<ú¥¯>ûÌû–Nø÷%ÿÑï€ÿËŸN0×0V¤³Éî£À-Î{<”Û‚@ý-0^d›ü$˜ ÎO$!Å8uBZÐK*¼Ü_ˆÂ’Å<E28099>'¯ñV¼žsCô)KV%ì!ÿ
j(¯ ±‡?,"L !ù
|
||||
ÿ , d < ÿ ÿ H° Áƒ*DØŒÀVB6m˜¸°¢Å‹3œÈ±á/<2F>C‚ÔH²$I<>e$>D±¥È”0ÿM3I³æÊŽîrêÜ9r Ë—*m
|
||||
½(&OYg ]zÔçÑŸC£24š4•Õ«X³’“É´kÕŸí(JÊ2k’³hÓæXëµm¨·]cŽYÖ,°»xó²ýZõL5<4C>Õ†Ët.Ý<>Võæ]܆–ÇkoHÜ¥²=Ë—µ
†jآǾj7M:Î?Ó§1§ÆŒÙoRÎ<52>§rµ+º´m ‘â|ØÍºwkÂ@cô·'%èеo_Yž7oß½]>¼8bäÉK3¯·]ÞsèÑ<C3A8>Sÿ¿©òxÚì=T¤_Î}€{æßÁÿ?–¸ýû³ŸOŸ¡¿zåc´Q<C2B4>{3Ì |ò…WO6Ýçàuûù'Œ„üý§Â<C2A7>¨!‚ *(Yøá¤_„za¢@b¨áŠv8l%=8ŽQ(@à@‰þ¥hâ‰ö¨"‹-º˜Ù‚Cɸ 6n‘Œ-wì€Ç“x䈢<CB86><R9àŠ6'ä‹E… 7U4s€wÔðÆ™hB©ƒ„ÿìèæ›X©å–C:"<22>ô$óˆ™èâƒ6üs¦“O² 'œqf9'<27>HIõ%˜è)C‹Ø` T@ñ<>
8ˆBèšo†ša¢ï)$‘\ÉEÔCºø€¤“ÿaŬÿœ`«%ƒ <20>…šUö:*©¦žJNy`‘7Õ£AŒyA¬%@c« G@k…
º~ê믤*ê£<><C2A3>õ¨·^’7¤°bú,´èÖÊ©§ÅLxí<78>À.Ê<C38A>ß&ðèD”£TLFB<46>ç#èÈZʹѦKE®Ö
|
||||
„(¶q+ìL÷âë@36âû%½2ú+³Íl0Âí¾o¼ÛÎKo«x‘PËľè{1K)¹š'Ç\-îŠze¶í•l2«Ø˜ˆÊ,Û»¯CK0 ™ÖŒn)¸&Üf›“ì3£''€ïCí2Æ É¼¬À;m´7ç¬3ÃÚÆ÷0«õ½µÑ/?X=c›ëlÁèJÿ²ÚVîlµÛ.q݈<C39D>ÉÍká~™Î«4ïÝ·ßìâÜ+#Ë)¯°Hùò¾_Ë•˜y—]ó´ƒX›#欷78á ž*¸3ÆE<C386>G®n܉ޒßjÉ €³®#Û=_Í9íÈ# ÛDÎü§é¶:(»S˜y©›®YòªBôáFãæ^zÇPwºÃS¬^áðÄg¯ýVÜÇè¸ÒÑüi) fª<66>þ<EFBFBD>§¯]àWrßû:?<3F>0OfŒX’þð°¿:¤Ïzý w˜ù F‡áˆÖj$4ôX<C3B4>=ÝY
·.ÃX'?$QýG5‡ÁÎC$Œ<>‘®âAÿ9G7Æ{¡j ó—ÊðA´ˆõæ3:
i3äH"çâ9F¦Ž¹<C5BD>#3Êä;ÒùG·à·Ä"M‹´!âb¨(<28>Áh†2G¼ •ØE&Ñ5E£Z<C2A3>È8¼Åw¤ã°ÔØÆÎàÇ<rcãBH>B¥€ãqJHe–:º…{¢cci¬GBò’ˆ¤äA<‡ÉN¥(2 ¥&7ÉIO‹'¥å(<28>•JSz)’A™$udT”ZºR&¶Ñ*3BËWºR—»Ì`ˆr‰b˜Á4`/qYÌø!3™¼ì¥ƒ¬3Íj>š'ÌŒyMlvÉšàôf"ÁNqŽ’œ6 !ù
|
||||
ÿ , d = ÿ ÿ ¸iÁƒ*\Ȱ¡Ã‡»m<C2BB>±bĉ-jÔXæ_‰1nYÑŸI<C5B8>&O’Lø±¥Ë•%;ŠT˜²¦Í›*7ºÜ9&K™ªÄI´¨PŽ<{ú<´iѤO<C2A4>B„úÒçK§£‚¤ŠQêT®0·bE©U,׳f"X˶-Ù®1»†”‹¬GYBÈå-£·¯_»wÛ
|
||||
üó-Ö²tý
|
||||
L +U¨3<C2A8>k“üO²åÇY .ØÌy0a¦YášEœóåÈ<C3A5>µT«ü¯‹j×°a_&ËMWgÏŸ5<1E>¸wcÎŽƒ·~=\žñã‘>(_n¯y¨_zÛžŽ›pèÝu1â-<2D>:‡÷šÀkÿYŽ|•ùó<C3B9>Ò—½¶{ê·sóÎîn»ýÓâ¿ÇÙý½ÿ ¦çßz˜UAÄ<41>ð ø^uJ å[bïyWNpR¨_~å
`v €Ì5gàˆ$Â7ƒ…ö K¶X¡‹°%ÉyÖèူ¥£ãŽ *Èà\*žx‚À™Ä‘(iä…¯<E280A6>Ç<1F>6F9 zöT<04><šøãŠ<C3A3>ù’Ž `Ö!æ˜JC“Î8£†~ᦔª·^3tBPg‰ZÒ'$‚V‚i#€’&™üq&“gªi^›o6zcœrvQg ƒf¹à–‹m6b˜¢BÀ§j„º…„z„
|
||||
‡¦™!£ŽÂ©<æÿ`Ь±Òs§<73>[î‰ Ÿfxúį ŠªÃ°k*†¦êd‹²Új«ª'&(’˵˜$#¥#æÚÒ®ôªÊ¸¼an°Â‚`쩨&‹!³>-‡SÊC˽®Ü+ƒÙÚzežn}»i¸ä–û碛®
|
||||
»ûîšÎÊû(zÆ•b1pàÃ"üNëï¥BîT›Ž‚ˆ[ð?'jYà±m«ì“lJ<o´ê!q
+Ð\¼1-°®W–l²Á)«ÌòÅ\òò?17<3ÄÛ<qz#ð<>ÇÎ>o4<>¸J7rFüiÒJ/íòÓQO
¥ÕÎâˆt3óI cÐ"0ÿbå<62>¸qCrÙãðÚi7m»Ý,Ü®¢GwÝ<÷lùÞ`<60><>Ýv Ù}øÁˆ«½ƒâ‹Ë,žqoC-Å“ƒcwå—óƒ·Â÷9Ù¨ˆþé8pœøâs̱¸ÃË>Ëûì´ëýBæ:hÛ¯ô˜ 输¼%
|
||||
Ü¡r1§?GãMÊÓúòô;!Ÿ°bBô{³Qíµ~|=ièÝ“þðŠkò’W3öµvtÓZäwú)"öC‡ó§` "ø<>Ù6X:–!§sZ»EµªYy „ýöfêk‚ù{Ðö5=•nƒŸRã 6³Õ•ЀT8ÿØÀ"^Nzx¡”øÂŸOƒP´àÊZ&Œ*f ‡Éû¡›·µùå툃<CB86>aôõÀ1N¯‰h4{ש6‹éÓ¢ëäfÄ/"±Œg\â÷(Æ4*Œ<>â
|
||||
”˜RD-^&”X´º<C2B4>·Œý,_I´Öýð‡ÇÆ0<C386>j ÃEªN: I†,Ô?Ö9HU,]sâô4p z`pZ”Œå%Ñø)Mn‹“•JÒwvIB9*g®aa0XHFê {ÍØµd¹Lü)Ñ–m$UѲ§,^Z“f4á"ƒIL'bPÙ[¬°EÎfÆš%Ë¥Ž^tÍCb3›7k^sT Ã\hlï¡Ó8Í™ÿ-l½r“ê§{PÀÎvúPQðl”<<3C>CÉUfîž0Ñ\ÙÏŠ.S[µÓßÂi©Û¤Æ ¼,)ƒhçèEVšì›Ð´#JíÓ¢=¦DA8<>v¤h" ܨdÒ_øƒ{µ TîÚÂ'}¾4[1<>(ȶ„œÆQFŠ"POQ‚%¥ÎT0
|
||||
êE‘z=|Ƈ>7ÍieŠœaÆ)ÚKkàªZ‹TÔ_ÕÑf°¿ò£ÖljlØC×¥®5ZÅ \åê§èµxÍ+b{ֽ؄CóLV‹*ÔŽRä0óá‹fÃꢛΆ4ÞzÏdQ<64>Ž }5³ µ«g«˜èÐÕ)¬hq¤Ës¦³uUíj!ÛÚÔêi¶5‰o¡SŸÊÄ6¶Ãý-Š’–¡$7)ÇíÇstÛ±Xeº¯EHN@»”¸L×+jAmw‘Zî:·ã]IyÁû•ª¤·»F9‰|Õ[]ê¾7,쥯mï{]ó’Ķ™á¯€¼_Ø' !ù
|
||||
ÿ , d d ÿ H° Áƒ*”U†¡C!
!>\HQᦋ3jÜȱ£ÇŠ$ŠIò£É“(Sª´q¥Ë—0»…œI³e͘,qêÜÉÓæÍŸ=ƒ
|
||||
•™ÓçУE‘*]JÔ(Ó§[EuJu$P¨X¥&šµëÕ¦`½rK6ìײ[šEËößÚ´lϺ<C38F>Š€î8»pãÖÕÛö.Þ2Y윗/áÁ‚oRü±cÃ<63>#Kv̸rãÂo3¿´\7<>çÏ<C3A7>Cû½LZs`ѨA'V<>ºäÙ±§[‹þS޵mÖ¯sǖݹŠoÚÀ¹_Í[·ñØD’ÿ^®¼¹sáÐQ%>ùêçÌÓeÇ<1E>›ôŸÔ'/ÿ½¾€»öó臫WO¹ø÷ñÄͧŸOß»}]÷Û—¬Íþçäå‡V0`}ÜåÞmšfgä5W`3VèÀ„¸]wJÄ ám6
x½<78>(`†¦¨"‚Ìýçâ‹Âö ]&Ò†b 8æXËŽ9¢È"€5Âc*26a€ÛÝÈ£Šô¬h ?&è¡<C3A8>güCäDÇÍåtôM¸¤Ž_šÓ¤“n%ˆX:tÆgkVce*Õ¸fÜuz&˜ˆ &™u¶ˆ&•pj¢Å 9´™&IGÚx¡’{ê)fžô@Ú£<C39A>(”)%’©$Q覄v
|
||||
œŸ’#j¨¢Ž¡<>>
|
||||
i2yŠÀꪒNÿZ欗VÃi¦¸v‡®¶vÑë?öØzXhÊ‘™ã«®j ì4«¬«ÈŽÉ§¥(äÚæ‚f«ë®Ü~àí·ò„ûÁ‚¾-j'ŽÈ6ËÆº!´ëC»ÎBëŠuhÌ› À`mÛöÛm$ ÿóO bp ä2i2øá.PD\ŠÄÁ¼ï¼ŽNá€Æ›Lµšêë©¶"Ãðï*(üO,·AT÷¡Š.ÃÛ q)'°¢ó:OlƒGË DYàÇ!“¬´ÉLs‹ò=P»¼ÂÔ_Lí—„{¦J³7ç|
y€Ý‡ &”à3ÐAÃ:4Lj40=$÷Ü@ôÀÅ¿q ìrÕS÷ÿíw‰çâ¹58ñu6?£8âa“
ñ»2à€¶¼ó²]G˜g®Âæœ<C3A6>áùÝu?-ð¤ûmú
|
||||
XSøªªØ"B³\›mBˆ<> ¸<>@Hâ_q6ä5ÿìêkíÅñš#¯<Ÿ×3Àó£ŸîÄôÔKàŽÿ´úººã|8· þø·³¾SÁ<53>ÀϬ«[ÄO‚ôÇ/Ì%ø“øóß¼ó¥“õú¶œ
|
||||
n{ïRßÄ7»l€<6C>|Ä<>ùa¶õ±Or“«êG¿Wxp
ü`ÂÀ¿”Єѓ†
|
||||
ÈBÔÙ)]´`Ÿ½F6f<0‚œ ú÷®bðb:€Ÿÿ>˜…"†P„#<áèþ1µ¶p€æbÝÖеy lÇÀ¡yÀ
|
||||
òЇ?d–ïPÄ! GD" •0ƒ[ÜâNl<4E>Ÿ¨ºtqO†ÞC„Øl¨Å-î£l6cÇHF2‚<10>hLãéF9HÑ*”ãY †mÏY«YiÇö‡\dé¾Rà
ˆL¤"yHFR’Oœ^ë Õ0î½ <20>Äb'm÷Iòñ ”„« 4\1ˆb¢Í”§L¥*W©„VþÑrl<72>4c)Ëd-ëŽxôZ'=ÙËR°Œ[ÄŒ9d¢2•«a#¡)ÍvRÓ –´¦ðÊ»n³›å :9ÿ¶~Ú€œðúa2ÑÉÌ9´RbHh;aùD;ªëŽ›DÂ
ñ)>.†M˜CøÄ0ÿé®y”ƒH'ªÐ…Nr€´¼f¼.‚*ÎÜ¤èø²aˆõŒ˜¤tßG—©¿,Ò -©Ic)Å´±45%Ü,È N™Vt‚'°BÎpšÓ<C5A1>t
xð©I*T†¶pGñÔ ö"Ç5.¦øü¥ËÆ3bðTæUÉÕ®žtzZX<øºÈ<C2BA>À ýt Z?©Ö?ÊŽ£dZ\ƒ'
|
||||
eŠT<EFBFBD>ìªWYh
|
||||
<11>¯³Œ\*êÛ‘<C39B>ícaá»<C3A1>v®æä)T¡¾³ŽP›öúZ
|
||||
ÆÿqŠ#ì/)±ÖÒ"VŒ•\!‡ÛØÇ~°‘v¥&ÍüÀ\±Ž•žïúkÚñ<C39A><C3B1>·:ücú~kNCrµ‹Ô*dåÐÚɲ<C389>¥1¤Å-›K¹`ÓÐ ìvÉKëîvø]kÁ¨ÁþžÑƒY
0VÚÌ[¼ò®ÔKl1ööΖ¹
–<> {<7B> P"|ö5~ÅFÚý^ð}Û[ÝÔ Õ;X¼âÅáè
÷-Â
æ®XU*a4|/Ÿ¼û£5êáÏ¡jÐ \Gd[ôtÀ ÖŸ™(À˜ÁE°X³ì88,V÷©è#Ï*èÖ)ËY$²<>ÕÀÁ¬"™~Ë{^ ©ùä¬/ÿÂ8 ªü
|
||||
<EFBFBD>ã¸qÂ4Û‡ÇüåÙŠ€ƒòÛ <20>æä9OÍMÎdŒÕ«^?´wftçmÃ7Ú¨*ƒËR†Ÿàˆ[BZɳ[èÆ· ~v0^oœ…'Øì’Þhu§»ûVÆš¶ì8ݺ2:Ô T¸H5¨=4ÕŽf“DàjÙÅú³ …v6Æfé.¯:¶Ëf]ÑýkÈ[%×°†É‡<0E>BgJG3ÜÛlX¢Âµ“u8yŒþæ:Ý•-Þ¶í×íoÃ-iÁòU>Ыo=k¥÷f=Ž*;Xs2qó¦7Ë)¯fàû7Q¼SñüÝ4OÙŠT¯†5}¡ç¬›ÎÐÿHù³#žr=ONÙ8ÒŒ*8Y™ÌZS"Õ”*©6tûé`w×Të.R{ªQv°ž ÀLõ‰Z¸Â<C2B8>Mt.„rm=øIN3f œµ¼ÎC[ãŽN…LüäYO
Ìd"Y€ªHSúy‡zt‡-PªDïgµ9êå˜kh:j{Ô÷ø(H@̦˜â¿žTö]Ûï¿qÌôžÍH˜Z8l¦xλbœ
òÒŸ„ù÷I?–—ÓFßÍ/8<>§ýqÆH/y©^)†úáçŠC>òµ¼uPú /7mæòSðM?¬Â;ÿ.
|
||||
J
lWgqÚ—žù¨ŸKåq/ùrA<72>òË?—TN_"]ü¨‡ÐˆJÃ}Å=÷å ÿö×OÿÝÌŸõò7fÚ<66>ý÷GÿþâwL" Ѹ¶'"ì—Íw{ è Ø€¥1xø€+A<>ˆ<>ã¡(~A€¨} X‚$X(€%¸‚!<18>(¨‚,Ø‚¸'X<>1hƒ7È<37>3h<33>üǃ9øƒ2ƒ@X<>ˆƒ‡²€ !ù
|
||||
ÿ , d d ÿ ËH° A*<Ȱႇ#r+7‘¢Å‹3.Ô¸¡£Ç<C2A3> mt²$É<>D V<>ÇR‚Ë•-YrIÓäÉ›6kª„³çKž>yÎÔ™gD£
|
||||
/]Ê4¨Ï£D‹"<22>º³éS«NŸ¢”ÊuêÊŒXej«+åÃ*g³VŒ:®«[‰a—¦%k¶¢L´Dðªýš–-U‡ öælW0a½U±"@ûöï†À a:Ðl²\Ä_3^»³âÆ~ÿ<>•\¹t…Ξ
Ó;—)h¨H [†@»v껫U÷-ÓïëѤgŸ¾ªº8k ¾“'8(;®ótƒi£6^á±Èß\•fµ-Xºdç¼Söÿtœ}ºyîÑŸ«<17>ùã좗kGýÝvú÷¹ë__´uù©üáKpûW`æ'TY¬aYkµ™!~ ¦3á…"8\V2\-jâˆ$–há†""ר{Àñ&\ГŸ¢‰4Ú&ã‰Ay߃<¦GÙ<47>5N"C–ö#<23>4v[y=ú$’‚XË”1Òs$‘RV™¤wf1Ùd<C399>O&"£˜dVIå•gjy%‘\ªÕQ*9<>à—<C3A0>(¤•Y¦©çžz> Óot*ˆa‘GòihŸkfÈXQÁVg9a*é™Tj锿dš=—bše<C5A1>ŒŽåáO|ã˜FâÙ©¥"°êê¦Âÿêi’þùX 1•Š"
|
||||
ƒšéé«ÉÄ*,k¬±$Û©‰µ¾Ùh£±é¤šÚ¢ì±2û¢p+ÊÏ kí¸i†(•¸
|
||||
ú¯l
|
||||
¬Æf+CÞ²1Ƚõ~.¼ãnZî„ÍÊçaº»â¸.ª¿úl°ÅÎKozØÀËÄËPlo¾Çò[i¢´I5'Á8†|°Œª¾îÅSaE!FDÜrÅ_ìm¸ýZK 3ºÇ´;¥ëÏ¿&ÌjÃ(sPÈH?àÁÑ,·üò24ÌlÍnØ\¤†èî8XžJrÉA/ïwÌ[ñÑ‘¶ÚLtà6ÓMC-u²6+;E„^‚üµÐ«Âÿ:¶Ã
|
||||
,½6.„Ç`ø9…³
KÜsk°…Uãü3y‘6ßÀ^„àCàÂÂç “ñùሿírã<72>Û]Û‹šTt{cþϵbÿ
±
° ýIè³ôÞ;!€„N:ãÛÖy‘[mÝš¦ï*L·°k ˆÙ¹ã9ð¾ =8†tÿûèj/s·ëŒ{ü<>£;»7“]Ãû
‹;tô¶ß®û<Œ€Æöü÷ÿ=án‹XÔžQ¾Ç™ÏJ(눩 ëšSÀÃ?úU~l˜—î—?ÿy<C3BF>Á3\Óh0@ªyÁ<16>£Ì³Ä3Ö€^–À1J@Cr@‚œ¶þ¡éMÐ~GøÄ>ÿ°÷Á"~¯p€ƒHH3ÇAÎ7›˜ØÕ(z@Pe%ÐÝ>þ<>ˆ ÚPb>£¼âÅà N,w4¢CxŽ$:‚s@ÆPøÄ.§™XÉÏP ÀÅà›Óݘñƒ &ð"yC1Æ/‚1ä ¡Æ5²ÀpIœƒ&•`FÎ;Ù#Ï‚<C38F> í1ÀðqŒ ìÕŠ\¤FËHÐIÛ+÷WI#‰ppÄh†˜Ï
3ðBZb¤ MìJ¼È"*E‡=V² ûèâfÈHÎÒ–<C392>Ãâ'¦ÉË^úqJt„0£ðÄ(á<>uúÇÝD) -°AHKå*ñÿýµÒ•Ùô"7eø,á
ã"O<>ÈAƒ{æôå%Ý8LNV<4E>ï¼ìÄô“”$žG›æ>û9V<01>¡JÚH,jñŒè9Û¨‡7ÞÂQÈè-¼Aªy:óg<>æÑô¹J’æïŸ(E),çÁT¦”
|
||||
E§Ç9ÑAT¦E¼$… G<>zúÊAi#Vù8àøìÜ>ùiT“* 'u*T9àRiN •WŪµÊ2uvõrƒ8ÚQ‰œ5†„býG üq<C3BC>®ll\¹‰@|¢SÍF9õšULÁ¯€¬`™Ù¥¤œµ¨*QIjT£>V²KE%ôg€<ÿ`i”Ì+gýÇÆ"˜4<CB9C>ƒpE‹>G- "P@j‰
|
||||
Òö(<28>m[a9<61>£ÖVey0€e»Û½Šð·Ÿ
,5@A^7pôŽ(Á@n«Êæ:
Ð}euYûC1ˆ,¸n!Û9Cê¶»½ý#à`ò’·Å]R¬ˆÚqæV{<hl8x€M€ÎV·, ìuKPRW·»ý»¤g•Hà˜°è…J3’Qƒk÷Ãÿ,)\çaJ¼rr½Æ†ƒGUî‚X{"~[0Ml`j„Õ¸ÜXqr© S.>4›þ<E280BA>/J÷gãlâx% ë'pYä7ãôï<C3B4>gA†ÒùÖiI$ðxÌ%GI€ÿS-Ç•¿œ‡}d÷¦ñ<C2A6>›ÊÍ"èaÜ28²‘˜Ž¹·gNg<4E>Õläu2"Ö\߯N™µ#˜ ŸUjPlÙ
|
||||
èð<EFBFBD>b<>=í^x·A>³Ó\à˜ž¨²<C2A8>E0êö’Ì‘=ꦻÕÀMœƒ`B¡É€ë˜bµÌmÚ<1B><>æV·ÀF³ž<C2B3>´<EFBFBD>”,„ªlÿ`AR¡¼ënû›÷
|
||||
ç BÊÜco„o,ñš£ôÀŒmÌɺb °ÍŒy@9¥rí5½0˜ÃânÞ5¶/µ{n.C<>Œ/mª¥-é] VUc±¨p9aÏÝöæÃÿvÁzι¸À[Rgжàÿ'¡:‹Œ%†]<5D>‡G!Ý^.ošÏOµA¯ÝÇó˜»/ƒá$÷ç¬ÛACÑt«†\ñRãÙœâx¼Ü02<>®5d)éªoŸ{ý}Ó7çˆZȈØì‡CZÜ,6@M:ý£c³ ü25s<‚
|
||||
Àìææêf¹‘û–Æ|N=€Üm%Û:pU>éøj;`½1Z—ËYt7Ñ‘w¬[áï*<üj7®“ýŒäNã¿ÁÇ[_Þ‚\F¿Z)ÆïöÇÊ|[þ@ÍY¡ïQå»#1O»ú¥,—«WÓ~ÈÃÞ„mhƒ¾à
ËOæ¹Gàî<C3A0>$ñ‰‡žïàÇáÿ¾š¯ÓSì÷¬_š%Ö®t™‰™^P ¾`÷lýãòÅÒ}3kSÿoßRçú†PÃ7;™u–×-ör~I·€`ô|w,u}`Ew
×*Gv³vþçM8zÈ7eS6bn&(3lp<6C>t<13>«°
|
||||
Èõ€ÑÓCùGw«¡d/äoè€þ‚9ñÂ<C3B1>Ï—A)˜‚ûBu•òDÀqPØs08ƒ–6hKµ$…8‚<Xz„„t2*X3TÂ+e• g•-SG„º…ý‡ƒTt<>·0˜ó<Xx<58>rè…_˜"w*¨{)VµÐ}j¨…Zè„oˆ)Ã/shˆÊ‚ÚÇ.q‡¦ÿWA±r†{Ø5<07>…Sh‰dˆ<64>ƒø†x¨1b£ˆWÈx”v׉;ÈcQŠ=´Š?‡‰2¸ƒ˜4`C~3+ôñ¤ø*WÃh(«XKe$/:„yu'‹AS&„ø.œR‡6ò'îA"¼¸‡QÈo$Œ¬(ˆÔ"‹QbŒÇ<08>%á&-Ò‡åW<C3A5>:4F™ˆ<E284A2>Ô²pÌH"ÿB!ðÀ@ã:1WKw<>!Ø.úh&Ó"!'Êó(óh€—øŠ±¢{P¢Ž“v<08>ˆ(=“ôx<C3B4>´ô€ªã'¤R»«á1Z#<23>ó8‘Dc<44>ùˆ‘籑†±y‘¸Rw…HŒëèŽ2IJòŽ,Ù’”âÁ<ÐŽ3ù„4I›q“';ÍX0øaDY“*"”ì¡,$$ ©Ñø“½á”C™GÑSôä3½¡”Ky™²<>.PÙQT¤‘aÁ5–Yk<> q–—A—jY”¸z)–È—rù<72>¢—¯“•R•‚é–Z‘XÙ"©+¹±—`¹ Šù—·Ò3I™T¹$”Ù![iiÉ‘kÙ “I– žq\Vi“H¦™›Y™;#šm˜‡©”Óš£±š ‰›£i›;#”m¡<¼¹›ÌášÂY›ðhœÑGÇ œÈ™œ !ù
|
||||
ÿ , d d ÿ H° ÁƒþýC€<43>¡Ã…e"Jœè°!Ň hÜÈ<C39C>ˆ„* =~YA¡É“(7@T¸á¢8‹.c¾”I³fÇ‘$ÓéÜ™2eËš?aJt<4A>Ñ›Hqæ„À´çI¡gB
*UhыI+,
Â4@ –>ª¤*öªÙ£Y·Vàêµ™ƒ³UÉÆ-K×&Ú´Lײm¡.ܨpÿâÝ¹×ƒÃÆf9÷o`ÁƒõÖâ«7ñãÆ~/[ü÷§3áÂy+Öœ™tÅ»ž?SGÓ¥awÔ…w5âЯÝÁÞmõMÕ¶YÐM|£\ÞÈ}«e]9ïðÑÆ“ÇîM{yó®·û*׸R:Zͳÿÿ=žyöâX¿»>íýlx’‚‚g?/•#ŠÎåì‡?:<3A>?{÷#&`Iæa7Üv÷e’_nûý×uï§Ðu
|
||||
¸@ú-ˆƒúçÞ‡Õ7߈|Øa*&xbƒ :è¡rÊG¢€µp¸¢<C2B8>,Bøbz0ÆXa‰åÑH=7¢h¤†Ûq†äŽ<2Ùdjd‰B∤ŠÝ´äl:ªçŒ2Hå<48>D¹¥I_Zùdš=‚… MF¦9æly"–Yª¹&›i*_<>S¶%ç z*©¤<C2A9>|r¹g¢¿¹e€
|
||||
9è˜y册"š©•Žþ9¢<39>‚ιěj¨ tœ¦ª*”’}z‰tRÿšL¥zj©šZ•p:ê¨MЊk®«»k˜¯Š+°Â:É<>BGFk,‚œŠøh²‰d;Ŷ$,¬—µ¢*I„˜6¸aH¦6j«(hË-·Ì6›QDÒ¦ˆ–ÔÞ‹î¹ûz–®Zƒ²ëî»4ïŽÑÚ«¯VãšÊðgï$ÒRûj·4
|
||||
GðæÄrðzö«ñ„\õú°R/œ¬o«-.¬P·ÈÔ¼Ë! s§à¿*b;éœØ)s*û*EÁ±’0ðÒïºá´Ç7ã¬%Ï=ç×®·"̪5¥dþx-Ñ+#MgÌd—ý4PG=N›É¢\‹Ä-÷t?a7× ûf‚acÿ€wÓf{r¶-63`¸ö‰™m‚<1C>‹‡ü3÷!u×ý<C397>ëÍw«<77>ûý7à<37>£]x
|
||||
¤oac/³ã”¿pˆë°Ã^ùçyç]ò×#rìy˼î»à¢G!<é<>L’ƒé"cœ:êO¼^Àó“@}ô<>×M»íqÜõ¯º+í4èÁo8ñ§ Ïtê²:?ýúì»n}íð{êUÒ@/ß½òßç|øÃ_<æûýt÷8õ<38>á€Dàóª—5¼mu,Sívw?ý
NxÃc€ÿNÑ‹¶%ï~ñ‚›HÂ2Ð<32>GÜ[(Á¿QÐ‚Ä É÷¿Šìƒ«Yéöé‘P<E28098>`pßûÿRˆÂñ…\ƒ!ÿd8¾
ö‚0ÓØ¬xµÎ‡?T ·FDÌuñˆÝ!Çà¥D&f°†t ]wØö0‹YÜ"¿˜#VPwÌ*ãÇ×DÒ!<21>adWÅæ<C385>ð<EFBFBD>ˆ,áë¬WG#6ÒŽb¬âõ8Ã>ú‘ˡ͌!ÉQ2‘ФÜÝ)+R‚Q<E2809A>£ãïbhF^Òs©œ"C8+çáC ¤€þáŒlQŽu´Û0ÈàŠRÓ.E é7dè’ÛÀ,<2C>‰L¶Ò‰œc3c ¬RÒ<52>¼L¤4yi8ã—vKg
˜à…P …ø 9Á!€
|
||||
òºT$z€ÿŒ]B‚x{´ä+iY°Áq³ `(g2ÿ¨KlŒây
¦+À lücGÆE8ŠYŒ¢ˆÃÀÇ6Èð<C388>}2`—È`e5øÏKb²›“”åîÚ(MNœó<C593>ÒÜôüÀθ1
<„M1jÔ“ˆÅZ*w!M“ºÀ|ð]@]‰ÈNÆT¦žKè(؉Hl`Ä~8\q›"“¨É ç0,<2C>2 •R“˜Å¨¤‰L0„±©SØE>°UV’N O¤ƒUwç.
|
||||
"LàéMéàUŸºO¬d5äPÑÈŽÚUn%¥X—šÒ@Ú4yíegÏÆDÀ>‘ <E28098>œ,oùÍ›`¨Õ{A6¾ÌÊÿþ£ 8€Mq{´&xhðªÅgùùT‘¦ ª¥å#ù»5nª²cÄÀ0ˆ:zÛ('+\1Œš20<32>
LèòV€p¾à˜DjS{KdôÀ
½ À8Ó(¾]¬t¹½ÐÚ`×Û-p:£—ÿÅ'ª›Ý“@ˆŒÌšxãC<C3A3>ŽšÄDå¯[äÕJÀ ÄÍÇψ_SÆRÂ/¨hE-ÚËm@Î"6±(gT«0 '( ^¥-Š“è…–ÖCôuªNô03—ÛÜ–wè!‚yX¹Qš2~¶ñ£'8k„ƒ´:¼ï‘øáÉ •GöXcÛä>™Èaš_Ù¢à|ìÿÈÄca—UWXsˆ™üdâ.4Lã$¼©bYË •°”gD‚Èé¹Ì“5ó)¯U´&Â
òÅ>mèCG<43>t‚\tvÜÖ¸IˆÒ‘>3”å¶Í¾½ í…W©ÒOCW¸q5 é'iH®úv®Øê”vC*ttju¥}˜U{ñ×¼BY¹Ž¤8`;Y¶Y³½³ª™eÙc5ƒ<35>]2iï‡Ú–¾6¶Ó,_½yË.ÐÞæì\µ«lÛV#V<>å³\›[×Ò>™âÊ-ðs|#ÉË<C389>¾÷<C2BE>VÜ_ ?¹Ö•²i›+q÷Ô—ó]MfˆbW
|
||||
¢¬#q‹#ÝïÿŠâÂQɇ…ÜM©–ÃM²|k\Íüí¸^nnÚL+GÎ*N*:%ê<>å¼[₸ÐDþs C(ãùãøÏR+sx«ÈçMgTLî”ã¼iÜYÔ’®žõ ?‰o_¿¹ÚÛ"ö¡ïÌjÐÒ“Ösf”§ë$íøöº‰¢Sö¹»èïÿ±”n(›êçø*U‹ÎNñ—y<E28094>ï}÷;uì>¤çÝðÓJ|Ý7O÷Î~ë9VÑI²r<C2B2>ÝìŸO¼×¾ñ)È]W‰jÖ•>pÒËí4<C3AD>ýƒÚ*]|E§×½ìóÕ{WÝ>÷¨þìYÅz«bÈ÷¼òûÄ||;ÿùo'Öð1S*£ñ¥ûÑßþ…qxï}¯œ†jáfâîð|sžm<C5BE>W¿êCó·|þH©ß½lØ–2í€>þãÇ}‹!ü'1÷—È}ãG%W[—í¡Ø/<2F>A/M<12>˜Lw<4C>¸<>
|
||||
¸ärpÒçÓ ‚!˜tD°|Ü€<C39C>ˆ‚ØúG‚g2›ƒóR48 !ù
|
||||
ÿ , d d ÿ 7ü8Á‚ƒ
\¨° 8‡¿ œ8Ž!È%Žk˜°£Ç<C2A3> »‰G²ŒIŠ'Kª\ɲ¥Æ”0[e|™¥Í›8cêlÉó¢Å—;-º3gHžiöüµôbQ—P‰9RêS¤B²ÎtºAàÕŸV§<1E>6òjײf¿†mº–›X·XÅ®]ÚŠiM¡v}šuË·¯_²hëV+sî\™^¹~K
|
||||
.àÇ‚7Jž|6-S†#>¬YÙ2ÈÆ gŽì9®i®—÷úåF„ukÈ<6B>)Ëzš-ÇÍ‹‹ºöÕº÷"°cÏ&HûaêÚI‡ã=~uµï*Ðý×MÚtñÒ¹…– =]õï„¿jÿ-\»yÆé¢7/>1uöÌ×ì^¥Ýy…øsŽ<73>]nö›’<çÝpð‘wŸÊ·›€Ÿ5XàfÆ)¥àóýÖÛIm=Háƒì<C692>&`} rxbÆøc 2˜Šål¸Üˆ'²è!}ù9˜À‚7ö·aŒ)â(`3ú¨¡<C2A8>2:çc€¹šˆ&yä“Ò¤<>J6©ÛŒ"™e\¸äXL†ˆ”[BÐL^~9d˜T2X¦™žåH%‘<öˆe”dš g•s§<>d~¨çžr:ù¢u|Vˆç¢?ž A*‹Š©&jˆþ h9˜>—i”ƒ>Ê]—j^JU<4A>Nêbj ŒvÚ<76>(xZP¨6†ÿféd…ƪ)£œ~Ú)«âZ+ª¦i«–Äúšj¯ðª§oÃ+e©¿:,®Èr™l«ËF{«´ðÐÇ[ŸÐf iÔb[mµŠªê®ëb.·ìž‹,¹æ¢iG«*kí¾üöë.¬ÓÆ;¯&lðÁ½6ØÚ®Ž6Ìp ‚@Dzÿ*¬í<C2AC>åÖÃÆwœ²
|
||||
'ëp3×bŽÉ(—œrÊÖÞyjÀ#,s%žÐüq«€>|òììó@]KÄ-»sÌ3{\s%çÌ*É%ó,õÔ=WmõÐû}§À\£<>CÒo¼4Ó繫9T§<54>ŒÚ';¬¼[û;0ØdÛ<öÍ›Æí@Ä(OÿmÌßl7±öÚXO\4Ürkì5ÝuÛÝøâŸnu~^¹àTKœx×ý*ž ã<>;n³È†s·àÞ?_Žùê™[@téY¿Ýùìú‚úÝLïý<C3AF>ºŸö:ëÀîúë°Ón|í¶‹n7êšÎ<Ú”ÿ¼ðį¯õÉß¾üÞÜ_ÏåäÒ‡?|ñØ{JûÍÙã^I÷ìŸý?˜<>BÁ–ƒ!À,áàsÈÔãC=‰‡ðÐÿf<C3BF>
kxOWü¾öCèã<C3A8>ØPŸöF×><3E>ImÈØþ<>
Ëm£<6D>.p8 (4‰a€!üH‘
|
||||
ÀØ!'Ø€m¤09`GÀ‡Xð!lJÃ]ÿ¯79`áà àþ'€ý-aààæÆ7 NPà~Ã0Õ$¾ñìmƒ+ìW/(@‡ž<>
”`Õ7ħqzÜE
|
||||
ˆBÀ¡0ˆß7r<37>¶)AKp!t¡NtqYøØ]X©Z4<5A>9LcúîÖÆA™Œ~r´†!&QGú @Š˜<À!þ±?º`êø£'¡‹fð{\J<>!HfJHh
|
||||
†ÜE]ð<>Ç‘fì&%+ù=zHmŽóS¢'Àº<02>ògœØméJ.k‹Êj
|
||||
…]ör’K#¦û”9
|
||||
ØQ…S»Ÿ1ÚV½-2 1u´–#9È¡<C388>gŒ!: ÿ̱ ófÚT÷F †¿ur Æ$ªˆNv6o‹ÆhF‰&â~8œ]îy†Jœ‚ƒ<E2809A><˜òþ9…õ‰³SÌ6îçŒmŒb`àeÿ!EcMeÒ4g*}1À™†Q£4%Û†‹û‰Ttn éIx
|
||||
Ò<>3<EFBFBD>„1›jE0”<30>8€1¬Ú²&ðƒŒï4ß¹À Hȉüìg”ºÔe}<7D> ¸*øZ½A9†…bçÜ!„q¬.8*RÙZ8Þ!°dpe›\ªQq•«¡Ð!n Xµ“±‡ëÄ(ÕÔ m±Ñ$Ÿé¶…±Òú•)¸ß+›ˆ~†Sœ‚Ú,8±2ÏÿÒU´™H*ASšv3&mpaË,N5à<35>8Ūr—ZÜŽV·»](24ÑQà÷ºm4V=u×þ97·ÐõÈH¾ÆZ¥¹Ñ°Ï͛ٚ[ׯ~`Û!/ã΋^í’¶Qns¯–ÞB«ÑK¾I£/=Á[ÜoËxz}–ˆ†êWÈÍ,»÷U¯„<C2AF>&-põè¿ÎðÓ8gàO8ÂÆšÒÅr¥aÏyøÄZC\Åø;¦›o¦°iU`¹8‰Ãõúpxwœ)˜¬xT,1ç²õ<C2B2>ë¸M¬•°ŠŒ»gMnÖ“‚Lå(éÉY«‘”aUÙ´ò—-6æ./YË¢2š¾œä)¯iøG—Jp䨫ödˆÎ0Ãs<C383>Ù„ I9rzÞ³Ž(µ!¤šÉpÆ
žãóg])ˆÏ²’ˆC†'%͘N’l¶C'šRhõ<>æå_õ'Ó<>ÆW®&]+LWªÔqþ
¬ÅdäÜ%Õ”&<15>Q
^'‡Éœ6Ò¦/-Þò¼Czás¸”]";çEÔ³¶“W|í'ÛüdØ6vÒt\
êA¿
|
||||
ØÆw°“3S{<š™I¯]„¢r›ûÝÍv6FˆÓmlC{×î&‘Z „¡c'{Ú¸þH¾áMðÛÖw®ò¶]]m~_»0 WøÀ–HGúØ‹fö~øƒo°ÆÞHI@ !ùd ÿ , d d ÿ ÿm¸¡ Áƒ*\Hp¡Ã‡#JôG±¢Å‹3jÜȱ£Ç<C2A3> CŠI²¤É“(Sª\ɲ¥Ë—0cÊœI³¦Í›8sêÜɳ§ÏŸ@ƒ
|
||||
J´¨Ñ£H“*]Ê´©Ó§P£J<C2A3>JµªÕ«X³jÝʵ«×¯`ÊK¶¬Ù³hÓª]˶۷pãÊ<C3A3>+•¤~àsá‚N9¼wa‹ØN|'•é8I@#¼{<7B>Inx3Ö?…S€3„ÍÅåL…+.h¼Y1Ek›äû‡o1ÆLtþÉnЯÜìx<C3AC>âåÌ$3^v†ð<E280A0>î·Ë?<18>Q€ÄéŸi¬-À;É<>éÐ<C3A9>øAð<>v<ÙÓwRÿÀÖÛ&ê.tW„ôt¹Lð׉}×>á…ù|o|ÝõÓÈ?ùȇ“1á°“‚y<E2809A>QZ#†<Æ_äÖË?Ôæ\h±èƒÀ‘aè€ìxr»¹ Ø‚çÍ×Za
üóXm X<>1µ @G7™yHÑ{®A&£€.àMü¼¸Ýzÿà8b<38>GVmýÌX9ø¦Ñ„º}Ç$3Öa,ð5f„ú0Ð;lX„¿}Óäšœ@ØFÖ´‡Izæ$Mº b*ªÙOØÈ&ÛqQJ9$E*ªÏ)<29>VD'Ã6 ƒ45’$ãH•ñôB?»TZQ#“üµjltPeÉQ, h‚AÞ4àŸE±·Ó®ªö”É?üS<³”HT&–é©„a>Œj,LcàOå¤<C3A5>‚²t]î¸ä–kî¹è¦«îºì¶ëî»ðÆ+ï¼ôÖkï½øæ«ï¾üöëï¿æ !ù
|
||||
ÿ , 1 ? ÿ ÿ ܯÑÀþþñãÇ Ñ¯„vHa£F ´ƒX±¢?vÊ 4FG@><3E>ñ&1¨È@ c
8äH±L|â‹ÅMcšË4J1iR<„ø<:<3A>hŠn9=XNæ„þ²úË“BÎS?µnĪ•ëÐ^G0èv`,±ø]ý—Ô'Uvaó&ì¶²£È z7=ÜkÌè?µ<>ÚþkD'ž1NÕÆ"›µ<E280BA>Æxì2Œ-§ÇbËatkX-ƒÁ‡·õË2ÇxWlDa²çÙ n[RnÓ öòJ·&ærý^<{Rìœ¬Ê¦Ø …HÄ<48>Rüv;:»ß<C2BB>äZ¾ý/SCÏ<43>vY'ÿ¯:h‚$;ßÞu=sL«@+rßQ€söíc—@G¹à™5L u‘HùU´@<ÁUÄ<55>A ´P» <08>†vèᇠ†(âˆ$RôX‰(røWE !ù
|
||||
ÿ , 1 B ÿ ÿ ¸i Áx
â-hçÏ ÃþÊ”+Ób&…>ldl`ƒ]
؉¬8pAÈnwñk0‘"IƒË]\‘v-5DËXKcZŽs¸!žQ’øvm€ØÍåÃM`ü— RÇ—O¥Êl„ æÕ¬™dö‹h¬Ì¦
#ªeŠ ,Ù45ªMÓåQ°¹ÖdGÔ%Ã_™ºí6)Ö<>l˜»0fN˜<4E>2ùËÄn즋( ¶£9·¢cˆü ÔÙ™íb´PINn$<24>2ÛÁ¹<>Û’6Ö¤û*®»;s–2žj4ÁaÍ‘‚{(™ôéá‘c†lD§Ðr¬§ç¦ŠSç?ÜÎ<C39C>ÎSÅÑhõé~±köžñ¡ÙïìM÷<4D>‡ò%àžã÷ÕÏ~íÙægáÇ߀>¥ÖcˆÝW<>ò7`}át\ƒ&¸ 7b·‚vxVcÒåሠú÷O@ ;
|
After Width: | Height: | Size: 20 KiB |
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test_landscape.gif
vendored
Normal file
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test_landscape.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 B |
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test_portrait.gif
vendored
Normal file
BIN
vendor/symfony/validator/Tests/Constraints/Fixtures/test_portrait.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 B |
81
vendor/symfony/validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php
vendored
Normal file
81
vendor/symfony/validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?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\Constraints\GreaterThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new GreaterThanOrEqualValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new GreaterThanOrEqual($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return GreaterThanOrEqual::TOO_LOW_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(3, 2),
|
||||
array(1, 1),
|
||||
array(new \DateTime('2010/01/01'), new \DateTime('2000/01/01')),
|
||||
array(new \DateTime('2000/01/01'), new \DateTime('2000/01/01')),
|
||||
array(new \DateTime('2010/01/01'), '2000/01/01'),
|
||||
array(new \DateTime('2000/01/01'), '2000/01/01'),
|
||||
array(new \DateTime('2010/01/01 UTC'), '2000/01/01 UTC'),
|
||||
array(new \DateTime('2000/01/01 UTC'), '2000/01/01 UTC'),
|
||||
array('a', 'a'),
|
||||
array('z', 'a'),
|
||||
array(null, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(5),
|
||||
array(6),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, '1', 2, '2', 'integer'),
|
||||
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2005/01/01', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2005/01/01 UTC', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
|
||||
array('b', '"b"', 'c', '"c"', 'string'),
|
||||
);
|
||||
}
|
||||
}
|
83
vendor/symfony/validator/Tests/Constraints/GreaterThanValidatorTest.php
vendored
Normal file
83
vendor/symfony/validator/Tests/Constraints/GreaterThanValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?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\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new GreaterThanValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new GreaterThan($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return GreaterThan::TOO_LOW_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(2, 1),
|
||||
array(new \DateTime('2005/01/01'), new \DateTime('2001/01/01')),
|
||||
array(new \DateTime('2005/01/01'), '2001/01/01'),
|
||||
array(new \DateTime('2005/01/01 UTC'), '2001/01/01 UTC'),
|
||||
array(new ComparisonTest_Class(5), new ComparisonTest_Class(4)),
|
||||
array('333', '22'),
|
||||
array(null, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(6),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, '1', 2, '2', 'integer'),
|
||||
array(2, '2', 2, '2', 'integer'),
|
||||
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2005/01/01', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2000/01/01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2005/01/01 UTC', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2000/01/01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
array('22', '"22"', '333', '"333"', 'string'),
|
||||
array('22', '"22"', '22', '"22"', 'string'),
|
||||
);
|
||||
}
|
||||
}
|
35
vendor/symfony/validator/Tests/Constraints/GroupSequenceTest.php
vendored
Normal file
35
vendor/symfony/validator/Tests/Constraints/GroupSequenceTest.php
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?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 PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\GroupSequence;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class GroupSequenceTest extends TestCase
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$sequence = new GroupSequence(array('Group 1', 'Group 2'));
|
||||
|
||||
$this->assertSame(array('Group 1', 'Group 2'), $sequence->groups);
|
||||
}
|
||||
|
||||
public function testCreateDoctrineStyle()
|
||||
{
|
||||
$sequence = new GroupSequence(array('value' => array('Group 1', 'Group 2')));
|
||||
|
||||
$this->assertSame(array('Group 1', 'Group 2'), $sequence->groups);
|
||||
}
|
||||
}
|
445
vendor/symfony/validator/Tests/Constraints/IbanValidatorTest.php
vendored
Normal file
445
vendor/symfony/validator/Tests/Constraints/IbanValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,445 @@
|
|||
<?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\Constraints\Iban;
|
||||
use Symfony\Component\Validator\Constraints\IbanValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class IbanValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new IbanValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Iban());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Iban());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIbans
|
||||
*/
|
||||
public function testValidIbans($iban)
|
||||
{
|
||||
$this->validator->validate($iban, new Iban());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidIbans()
|
||||
{
|
||||
return array(
|
||||
array('CH9300762011623852957'), // Switzerland without spaces
|
||||
array('CH93 0076 2011 6238 5295 7'), // Switzerland with multiple spaces
|
||||
|
||||
// Country list
|
||||
// http://www.rbs.co.uk/corporate/international/g0/guide-to-international-business/regulatory-information/iban/iban-example.ashx
|
||||
|
||||
array('AL47 2121 1009 0000 0002 3569 8741'), //Albania
|
||||
array('AD12 0001 2030 2003 5910 0100'), //Andorra
|
||||
array('AT61 1904 3002 3457 3201'), //Austria
|
||||
array('AZ21 NABZ 0000 0000 1370 1000 1944'), //Azerbaijan
|
||||
array('BH67 BMAG 0000 1299 1234 56'), //Bahrain
|
||||
array('BE62 5100 0754 7061'), //Belgium
|
||||
array('BA39 1290 0794 0102 8494'), //Bosnia and Herzegovina
|
||||
array('BG80 BNBG 9661 1020 3456 78'), //Bulgaria
|
||||
array('BY 13 NBRB 3600 900000002Z00AB00'), //Belarus
|
||||
array('BY13 NBRB 3600 900000002Z00AB00'), //Belarus
|
||||
array('BY22NB23324232T78YR7823HR32U'), //Belarus
|
||||
array('HR12 1001 0051 8630 0016 0'), //Croatia
|
||||
array('CY17 0020 0128 0000 0012 0052 7600'), //Cyprus
|
||||
array('CZ65 0800 0000 1920 0014 5399'), //Czech Republic
|
||||
array('DK50 0040 0440 1162 43'), //Denmark
|
||||
array('EE38 2200 2210 2014 5685'), //Estonia
|
||||
array('FO97 5432 0388 8999 44'), //Faroe Islands
|
||||
array('FI21 1234 5600 0007 85'), //Finland
|
||||
array('FR14 2004 1010 0505 0001 3M02 606'), //France
|
||||
array('GE29 NB00 0000 0101 9049 17'), //Georgia
|
||||
array('DE89 3704 0044 0532 0130 00'), //Germany
|
||||
array('GI75 NWBK 0000 0000 7099 453'), //Gibraltar
|
||||
array('GR16 0110 1250 0000 0001 2300 695'), //Greece
|
||||
array('GL56 0444 9876 5432 10'), //Greenland
|
||||
array('HU42 1177 3016 1111 1018 0000 0000'), //Hungary
|
||||
array('IS14 0159 2600 7654 5510 7303 39'), //Iceland
|
||||
array('IE29 AIBK 9311 5212 3456 78'), //Ireland
|
||||
array('IL62 0108 0000 0009 9999 999'), //Israel
|
||||
array('IT40 S054 2811 1010 0000 0123 456'), //Italy
|
||||
array('LV80 BANK 0000 4351 9500 1'), //Latvia
|
||||
array('LB62 0999 0000 0001 0019 0122 9114'), //Lebanon
|
||||
array('LI21 0881 0000 2324 013A A'), //Liechtenstein
|
||||
array('LT12 1000 0111 0100 1000'), //Lithuania
|
||||
array('LU28 0019 4006 4475 0000'), //Luxembourg
|
||||
array('MK072 5012 0000 0589 84'), //Macedonia
|
||||
array('MT84 MALT 0110 0001 2345 MTLC AST0 01S'), //Malta
|
||||
array('MU17 BOMM 0101 1010 3030 0200 000M UR'), //Mauritius
|
||||
array('MD24 AG00 0225 1000 1310 4168'), //Moldova
|
||||
array('MC93 2005 2222 1001 1223 3M44 555'), //Monaco
|
||||
array('ME25 5050 0001 2345 6789 51'), //Montenegro
|
||||
array('NL39 RABO 0300 0652 64'), //Netherlands
|
||||
array('NO93 8601 1117 947'), //Norway
|
||||
array('PK36 SCBL 0000 0011 2345 6702'), //Pakistan
|
||||
array('PL60 1020 1026 0000 0422 7020 1111'), //Poland
|
||||
array('PT50 0002 0123 1234 5678 9015 4'), //Portugal
|
||||
array('RO49 AAAA 1B31 0075 9384 0000'), //Romania
|
||||
array('SM86 U032 2509 8000 0000 0270 100'), //San Marino
|
||||
array('SA03 8000 0000 6080 1016 7519'), //Saudi Arabia
|
||||
array('RS35 2600 0560 1001 6113 79'), //Serbia
|
||||
array('SK31 1200 0000 1987 4263 7541'), //Slovak Republic
|
||||
array('SI56 1910 0000 0123 438'), //Slovenia
|
||||
array('ES80 2310 0001 1800 0001 2345'), //Spain
|
||||
array('SE35 5000 0000 0549 1000 0003'), //Sweden
|
||||
array('CH93 0076 2011 6238 5295 7'), //Switzerland
|
||||
array('TN59 1000 6035 1835 9847 8831'), //Tunisia
|
||||
array('TR33 0006 1005 1978 6457 8413 26'), //Turkey
|
||||
array('AE07 0331 2345 6789 0123 456'), //UAE
|
||||
array('GB12 CPBK 0892 9965 0449 91'), //United Kingdom
|
||||
|
||||
//Extended country list
|
||||
//http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html
|
||||
// https://www.swift.com/sites/default/files/resources/iban_registry.pdf
|
||||
array('AO06000600000100037131174'), //Angola
|
||||
array('AZ21NABZ00000000137010001944'), //Azerbaijan
|
||||
array('BH29BMAG1299123456BH00'), //Bahrain
|
||||
array('BJ11B00610100400271101192591'), //Benin
|
||||
array('BR9700360305000010009795493P1'), // Brazil
|
||||
array('BR1800000000141455123924100C2'), // Brazil
|
||||
array('VG96VPVG0000012345678901'), //British Virgin Islands
|
||||
array('BF1030134020015400945000643'), //Burkina Faso
|
||||
array('BI43201011067444'), //Burundi
|
||||
array('CM2110003001000500000605306'), //Cameroon
|
||||
array('CV64000300004547069110176'), //Cape Verde
|
||||
array('FR7630007000110009970004942'), //Central African Republic
|
||||
array('CG5230011000202151234567890'), //Congo
|
||||
array('CR05015202001026284066'), //Costa Rica
|
||||
array('DO28BAGR00000001212453611324'), //Dominican Republic
|
||||
array('GT82TRAJ01020000001210029690'), //Guatemala
|
||||
array('IR580540105180021273113007'), //Iran
|
||||
array('IL620108000000099999999'), //Israel
|
||||
array('CI05A00060174100178530011852'), //Ivory Coast
|
||||
array('JO94CBJO0010000000000131000302'), // Jordan
|
||||
array('KZ176010251000042993'), //Kazakhstan
|
||||
array('KW74NBOK0000000000001000372151'), //Kuwait
|
||||
array('LB30099900000001001925579115'), //Lebanon
|
||||
array('MG4600005030010101914016056'), //Madagascar
|
||||
array('ML03D00890170001002120000447'), //Mali
|
||||
array('MR1300012000010000002037372'), //Mauritania
|
||||
array('MU17BOMM0101101030300200000MUR'), //Mauritius
|
||||
array('MZ59000100000011834194157'), //Mozambique
|
||||
array('PS92PALS000000000400123456702'), //Palestinian Territory
|
||||
array('QA58DOHB00001234567890ABCDEFG'), //Qatar
|
||||
array('XK051212012345678906'), //Republic of Kosovo
|
||||
array('PT50000200000163099310355'), //Sao Tome and Principe
|
||||
array('SA0380000000608010167519'), //Saudi Arabia
|
||||
array('SN12K00100152000025690007542'), //Senegal
|
||||
array('TL380080012345678910157'), //Timor-Leste
|
||||
array('TN5914207207100707129648'), //Tunisia
|
||||
array('TR330006100519786457841326'), //Turkey
|
||||
array('UA213223130000026007233566001'), //Ukraine
|
||||
array('AE260211000000230064016'), //United Arab Emirates
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getIbansWithInvalidFormat
|
||||
*/
|
||||
public function testIbansWithInvalidFormat($iban)
|
||||
{
|
||||
$this->assertViolationRaised($iban, Iban::INVALID_FORMAT_ERROR);
|
||||
}
|
||||
|
||||
public function getIbansWithInvalidFormat()
|
||||
{
|
||||
return array(
|
||||
array('AL47 2121 1009 0000 0002 3569 874'), //Albania
|
||||
array('AD12 0001 2030 2003 5910 010'), //Andorra
|
||||
array('AT61 1904 3002 3457 320'), //Austria
|
||||
array('AZ21 NABZ 0000 0000 1370 1000 194'), //Azerbaijan
|
||||
array('AZ21 N1BZ 0000 0000 1370 1000 1944'), //Azerbaijan
|
||||
array('BH67 BMAG 0000 1299 1234 5'), //Bahrain
|
||||
array('BH67 B2AG 0000 1299 1234 56'), //Bahrain
|
||||
array('BE62 5100 0754 7061 2'), //Belgium
|
||||
array('BA39 1290 0794 0102 8494 4'), //Bosnia and Herzegovina
|
||||
array('BG80 BNBG 9661 1020 3456 7'), //Bulgaria
|
||||
array('BG80 B2BG 9661 1020 3456 78'), //Bulgaria
|
||||
array('BY 13 NBRB 3600 900000002Z00AB001'), //Belarus
|
||||
array('BY 13 NBRB 3600 900000002Z00AB0'), //Belarus
|
||||
array('BYRO NBRB 3600 900000002Z00AB0'), //Belarus
|
||||
array('BY 13 3600 NBRB 900000002Z00AB05'), //Belarus
|
||||
array('HR12 1001 0051 8630 0016 01'), //Croatia
|
||||
array('CY17 0020 0128 0000 0012 0052 7600 1'), //Cyprus
|
||||
array('CZ65 0800 0000 1920 0014 5399 1'), //Czech Republic
|
||||
array('DK50 0040 0440 1162 431'), //Denmark
|
||||
array('EE38 2200 2210 2014 5685 1'), //Estonia
|
||||
array('FO97 5432 0388 8999 441'), //Faroe Islands
|
||||
array('FI21 1234 5600 0007 851'), //Finland
|
||||
array('FR14 2004 1010 0505 0001 3M02 6061'), //France
|
||||
array('GE29 NB00 0000 0101 9049 171'), //Georgia
|
||||
array('DE89 3704 0044 0532 0130 001'), //Germany
|
||||
array('GI75 NWBK 0000 0000 7099 4531'), //Gibraltar
|
||||
array('GR16 0110 1250 0000 0001 2300 6951'), //Greece
|
||||
array('GL56 0444 9876 5432 101'), //Greenland
|
||||
array('HU42 1177 3016 1111 1018 0000 0000 1'), //Hungary
|
||||
array('IS14 0159 2600 7654 5510 7303 391'), //Iceland
|
||||
array('IE29 AIBK 9311 5212 3456 781'), //Ireland
|
||||
array('IL62 0108 0000 0009 9999 9991'), //Israel
|
||||
array('IT40 S054 2811 1010 0000 0123 4561'), //Italy
|
||||
array('LV80 BANK 0000 4351 9500 11'), //Latvia
|
||||
array('LB62 0999 0000 0001 0019 0122 9114 1'), //Lebanon
|
||||
array('LI21 0881 0000 2324 013A A1'), //Liechtenstein
|
||||
array('LT12 1000 0111 0100 1000 1'), //Lithuania
|
||||
array('LU28 0019 4006 4475 0000 1'), //Luxembourg
|
||||
array('MK072 5012 0000 0589 84 1'), //Macedonia
|
||||
array('MT84 MALT 0110 0001 2345 MTLC AST0 01SA'), //Malta
|
||||
array('MU17 BOMM 0101 1010 3030 0200 000M URA'), //Mauritius
|
||||
array('MD24 AG00 0225 1000 1310 4168 1'), //Moldova
|
||||
array('MC93 2005 2222 1001 1223 3M44 5551'), //Monaco
|
||||
array('ME25 5050 0001 2345 6789 511'), //Montenegro
|
||||
array('NL39 RABO 0300 0652 641'), //Netherlands
|
||||
array('NO93 8601 1117 9471'), //Norway
|
||||
array('PK36 SCBL 0000 0011 2345 6702 1'), //Pakistan
|
||||
array('PL60 1020 1026 0000 0422 7020 1111 1'), //Poland
|
||||
array('PT50 0002 0123 1234 5678 9015 41'), //Portugal
|
||||
array('RO49 AAAA 1B31 0075 9384 0000 1'), //Romania
|
||||
array('SM86 U032 2509 8000 0000 0270 1001'), //San Marino
|
||||
array('SA03 8000 0000 6080 1016 7519 1'), //Saudi Arabia
|
||||
array('RS35 2600 0560 1001 6113 791'), //Serbia
|
||||
array('SK31 1200 0000 1987 4263 7541 1'), //Slovak Republic
|
||||
array('SI56 1910 0000 0123 4381'), //Slovenia
|
||||
array('ES80 2310 0001 1800 0001 2345 1'), //Spain
|
||||
array('SE35 5000 0000 0549 1000 0003 1'), //Sweden
|
||||
array('CH93 0076 2011 6238 5295 71'), //Switzerland
|
||||
array('TN59 1000 6035 1835 9847 8831 1'), //Tunisia
|
||||
array('TR33 0006 1005 1978 6457 8413 261'), //Turkey
|
||||
array('AE07 0331 2345 6789 0123 4561'), //UAE
|
||||
array('GB12 CPBK 0892 9965 0449 911'), //United Kingdom
|
||||
|
||||
//Extended country list
|
||||
array('AO060006000001000371311741'), //Angola
|
||||
array('AZ21NABZ000000001370100019441'), //Azerbaijan
|
||||
array('BH29BMAG1299123456BH001'), //Bahrain
|
||||
array('BJ11B006101004002711011925911'), //Benin
|
||||
array('BR9700360305000010009795493P11'), // Brazil
|
||||
array('BR1800000000141455123924100C21'), // Brazil
|
||||
array('VG96VPVG00000123456789011'), //British Virgin Islands
|
||||
array('BF10301340200154009450006431'), //Burkina Faso
|
||||
array('BI432010110674441'), //Burundi
|
||||
array('CM21100030010005000006053061'), //Cameroon
|
||||
array('CV640003000045470691101761'), //Cape Verde
|
||||
array('FR76300070001100099700049421'), //Central African Republic
|
||||
array('CG52300110002021512345678901'), //Congo
|
||||
array('CR05152020010262840661'), //Costa Rica
|
||||
array('CR0515202001026284066'), //Costa Rica
|
||||
array('DO28BAGR000000012124536113241'), //Dominican Republic
|
||||
array('GT82TRAJ010200000012100296901'), //Guatemala
|
||||
array('IR5805401051800212731130071'), //Iran
|
||||
array('IL6201080000000999999991'), //Israel
|
||||
array('CI05A000601741001785300118521'), //Ivory Coast
|
||||
array('JO94CBJO00100000000001310003021'), // Jordan
|
||||
array('KZ1760102510000429931'), //Kazakhstan
|
||||
array('KW74NBOK00000000000010003721511'), //Kuwait
|
||||
array('LB300999000000010019255791151'), //Lebanon
|
||||
array('MG46000050300101019140160561'), //Madagascar
|
||||
array('ML03D008901700010021200004471'), //Mali
|
||||
array('MR13000120000100000020373721'), //Mauritania
|
||||
array('MU17BOMM0101101030300200000MUR1'), //Mauritius
|
||||
array('MZ590001000000118341941571'), //Mozambique
|
||||
array('PS92PALS0000000004001234567021'), //Palestinian Territory
|
||||
array('QA58DOHB00001234567890ABCDEFG1'), //Qatar
|
||||
array('XK0512120123456789061'), //Republic of Kosovo
|
||||
array('PT500002000001630993103551'), //Sao Tome and Principe
|
||||
array('SA03800000006080101675191'), //Saudi Arabia
|
||||
array('SN12K001001520000256900075421'), //Senegal
|
||||
array('TL3800800123456789101571'), //Timor-Leste
|
||||
array('TN59142072071007071296481'), //Tunisia
|
||||
array('TR3300061005197864578413261'), //Turkey
|
||||
array('UA21AAAA1300000260072335660012'), //Ukraine
|
||||
array('AE2602110000002300640161'), //United Arab Emirates
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getIbansWithValidFormatButIncorrectChecksum
|
||||
*/
|
||||
public function testIbansWithValidFormatButIncorrectChecksum($iban)
|
||||
{
|
||||
$this->assertViolationRaised($iban, Iban::CHECKSUM_FAILED_ERROR);
|
||||
}
|
||||
|
||||
public function getIbansWithValidFormatButIncorrectChecksum()
|
||||
{
|
||||
return array(
|
||||
array('AL47 2121 1009 0000 0002 3569 8742'), //Albania
|
||||
array('AD12 0001 2030 2003 5910 0101'), //Andorra
|
||||
array('AT61 1904 3002 3457 3202'), //Austria
|
||||
array('AZ21 NABZ 0000 0000 1370 1000 1945'), //Azerbaijan
|
||||
array('BH67 BMAG 0000 1299 1234 57'), //Bahrain
|
||||
array('BE62 5100 0754 7062'), //Belgium
|
||||
array('BA39 1290 0794 0102 8495'), //Bosnia and Herzegovina
|
||||
array('BG80 BNBG 9661 1020 3456 79'), //Bulgaria
|
||||
array('BY90 NBRB 3600 900000002Z00AB00'), //Belarus
|
||||
array('HR12 1001 0051 8630 0016 1'), //Croatia
|
||||
array('CY17 0020 0128 0000 0012 0052 7601'), //Cyprus
|
||||
array('CZ65 0800 0000 1920 0014 5398'), //Czech Republic
|
||||
array('DK50 0040 0440 1162 44'), //Denmark
|
||||
array('EE38 2200 2210 2014 5684'), //Estonia
|
||||
array('FO97 5432 0388 8999 43'), //Faroe Islands
|
||||
array('FI21 1234 5600 0007 84'), //Finland
|
||||
array('FR14 2004 1010 0505 0001 3M02 605'), //France
|
||||
array('GE29 NB00 0000 0101 9049 16'), //Georgia
|
||||
array('DE89 3704 0044 0532 0130 01'), //Germany
|
||||
array('GI75 NWBK 0000 0000 7099 452'), //Gibraltar
|
||||
array('GR16 0110 1250 0000 0001 2300 694'), //Greece
|
||||
array('GL56 0444 9876 5432 11'), //Greenland
|
||||
array('HU42 1177 3016 1111 1018 0000 0001'), //Hungary
|
||||
array('IS14 0159 2600 7654 5510 7303 38'), //Iceland
|
||||
array('IE29 AIBK 9311 5212 3456 79'), //Ireland
|
||||
array('IL62 0108 0000 0009 9999 998'), //Israel
|
||||
array('IT40 S054 2811 1010 0000 0123 457'), //Italy
|
||||
array('LV80 BANK 0000 4351 9500 2'), //Latvia
|
||||
array('LB62 0999 0000 0001 0019 0122 9115'), //Lebanon
|
||||
array('LI21 0881 0000 2324 013A B'), //Liechtenstein
|
||||
array('LT12 1000 0111 0100 1001'), //Lithuania
|
||||
array('LU28 0019 4006 4475 0001'), //Luxembourg
|
||||
array('MK072 5012 0000 0589 85'), //Macedonia
|
||||
array('MT84 MALT 0110 0001 2345 MTLC AST0 01T'), //Malta
|
||||
array('MU17 BOMM 0101 1010 3030 0200 000M UP'), //Mauritius
|
||||
array('MD24 AG00 0225 1000 1310 4169'), //Moldova
|
||||
array('MC93 2005 2222 1001 1223 3M44 554'), //Monaco
|
||||
array('ME25 5050 0001 2345 6789 52'), //Montenegro
|
||||
array('NL39 RABO 0300 0652 65'), //Netherlands
|
||||
array('NO93 8601 1117 948'), //Norway
|
||||
array('PK36 SCBL 0000 0011 2345 6703'), //Pakistan
|
||||
array('PL60 1020 1026 0000 0422 7020 1112'), //Poland
|
||||
array('PT50 0002 0123 1234 5678 9015 5'), //Portugal
|
||||
array('RO49 AAAA 1B31 0075 9384 0001'), //Romania
|
||||
array('SM86 U032 2509 8000 0000 0270 101'), //San Marino
|
||||
array('SA03 8000 0000 6080 1016 7518'), //Saudi Arabia
|
||||
array('RS35 2600 0560 1001 6113 78'), //Serbia
|
||||
array('SK31 1200 0000 1987 4263 7542'), //Slovak Republic
|
||||
array('SI56 1910 0000 0123 439'), //Slovenia
|
||||
array('ES80 2310 0001 1800 0001 2346'), //Spain
|
||||
array('SE35 5000 0000 0549 1000 0004'), //Sweden
|
||||
array('CH93 0076 2011 6238 5295 8'), //Switzerland
|
||||
array('TN59 1000 6035 1835 9847 8832'), //Tunisia
|
||||
array('TR33 0006 1005 1978 6457 8413 27'), //Turkey
|
||||
array('AE07 0331 2345 6789 0123 457'), //UAE
|
||||
array('GB12 CPBK 0892 9965 0449 92'), //United Kingdom
|
||||
|
||||
//Extended country list
|
||||
array('AO06000600000100037131175'), //Angola
|
||||
array('AZ21NABZ00000000137010001945'), //Azerbaijan
|
||||
array('BH29BMAG1299123456BH01'), //Bahrain
|
||||
array('BJ11B00610100400271101192592'), //Benin
|
||||
array('BR9700360305000010009795493P2'), // Brazil
|
||||
array('BR1800000000141455123924100C3'), // Brazil
|
||||
array('VG96VPVG0000012345678902'), //British Virgin Islands
|
||||
array('BF1030134020015400945000644'), //Burkina Faso
|
||||
array('BI43201011067445'), //Burundi
|
||||
array('CM2110003001000500000605307'), //Cameroon
|
||||
array('CV64000300004547069110177'), //Cape Verde
|
||||
array('FR7630007000110009970004943'), //Central African Republic
|
||||
array('CG5230011000202151234567891'), //Congo
|
||||
array('CR96042332432534543564'), //Costa Rica
|
||||
array('DO28BAGR00000001212453611325'), //Dominican Republic
|
||||
array('GT82TRAJ01020000001210029691'), //Guatemala
|
||||
array('IR580540105180021273113008'), //Iran
|
||||
array('IL620108000000099999998'), //Israel
|
||||
array('CI05A00060174100178530011853'), //Ivory Coast
|
||||
array('JO94CBJO0010000000000131000303'), // Jordan
|
||||
array('KZ176010251000042994'), //Kazakhstan
|
||||
array('KW74NBOK0000000000001000372152'), //Kuwait
|
||||
array('LB30099900000001001925579116'), //Lebanon
|
||||
array('MG4600005030010101914016057'), //Madagascar
|
||||
array('ML03D00890170001002120000448'), //Mali
|
||||
array('MR1300012000010000002037373'), //Mauritania
|
||||
array('MU17BOMM0101101030300200000MUP'), //Mauritius
|
||||
array('MZ59000100000011834194158'), //Mozambique
|
||||
array('PS92PALS000000000400123456703'), //Palestinian Territory
|
||||
array('QA58DOHB00001234567890ABCDEFH'), //Qatar
|
||||
array('XK051212012345678907'), //Republic of Kosovo
|
||||
array('PT50000200000163099310356'), //Sao Tome and Principe
|
||||
array('SA0380000000608010167518'), //Saudi Arabia
|
||||
array('SN12K00100152000025690007543'), //Senegal
|
||||
array('TL380080012345678910158'), //Timor-Leste
|
||||
array('TN5914207207100707129649'), //Tunisia
|
||||
array('TR330006100519786457841327'), //Turkey
|
||||
array('UA213223130000026007233566002'), //Ukraine
|
||||
array('AE260211000000230064017'), //United Arab Emirates
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getUnsupportedCountryCodes
|
||||
*/
|
||||
public function testIbansWithUnsupportedCountryCode($countryCode)
|
||||
{
|
||||
$this->assertViolationRaised($countryCode.'260211000000230064016', Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR);
|
||||
}
|
||||
|
||||
public function getUnsupportedCountryCodes()
|
||||
{
|
||||
return array(
|
||||
array('AG'),
|
||||
array('AI'),
|
||||
array('AQ'),
|
||||
array('AS'),
|
||||
array('AW'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testIbansWithInvalidCharacters()
|
||||
{
|
||||
$this->assertViolationRaised('CH930076201162385295]', Iban::INVALID_CHARACTERS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getIbansWithInvalidCountryCode
|
||||
*/
|
||||
public function testIbansWithInvalidCountryCode($iban)
|
||||
{
|
||||
$this->assertViolationRaised($iban, Iban::INVALID_COUNTRY_CODE_ERROR);
|
||||
}
|
||||
|
||||
public function getIbansWithInvalidCountryCode()
|
||||
{
|
||||
return array(
|
||||
array('0750447346'),
|
||||
array('2X0750447346'),
|
||||
array('A20750447346'),
|
||||
);
|
||||
}
|
||||
|
||||
private function assertViolationRaised($iban, $code)
|
||||
{
|
||||
$constraint = new Iban(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($iban, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$iban.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
96
vendor/symfony/validator/Tests/Constraints/IdenticalToValidatorTest.php
vendored
Normal file
96
vendor/symfony/validator/Tests/Constraints/IdenticalToValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?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\Constraints\IdenticalTo;
|
||||
use Symfony\Component\Validator\Constraints\IdenticalToValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new IdenticalToValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new IdenticalTo($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return IdenticalTo::NOT_IDENTICAL_ERROR;
|
||||
}
|
||||
|
||||
public function provideAllValidComparisons()
|
||||
{
|
||||
$this->setDefaultTimezone('UTC');
|
||||
|
||||
// Don't call addPhp5Dot5Comparisons() automatically, as it does
|
||||
// not take care of identical objects
|
||||
$comparisons = $this->provideValidComparisons();
|
||||
|
||||
$this->restoreDefaultTimezone();
|
||||
|
||||
return $comparisons;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
$date = new \DateTime('2000-01-01');
|
||||
$object = new ComparisonTest_Class(2);
|
||||
|
||||
$comparisons = array(
|
||||
array(3, 3),
|
||||
array('a', 'a'),
|
||||
array($date, $date),
|
||||
array($object, $object),
|
||||
array(null, 1),
|
||||
);
|
||||
|
||||
$immutableDate = new \DateTimeImmutable('2000-01-01');
|
||||
$comparisons[] = array($immutableDate, $immutableDate);
|
||||
|
||||
return $comparisons;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(5),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, '1', 2, '2', 'integer'),
|
||||
array(2, '2', '2', '"2"', 'string'),
|
||||
array('22', '"22"', '333', '"333"', 'string'),
|
||||
array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999, 12:00 AM', 'DateTime'),
|
||||
array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
);
|
||||
}
|
||||
}
|
411
vendor/symfony/validator/Tests/Constraints/ImageValidatorTest.php
vendored
Normal file
411
vendor/symfony/validator/Tests/Constraints/ImageValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,411 @@
|
|||
<?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\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\ImageValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @requires extension fileinfo
|
||||
*/
|
||||
class ImageValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* @var ImageValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
protected $path;
|
||||
protected $image;
|
||||
protected $imageLandscape;
|
||||
protected $imagePortrait;
|
||||
protected $image4By3;
|
||||
protected $imageCorrupted;
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new ImageValidator();
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->image = __DIR__.'/Fixtures/test.gif';
|
||||
$this->imageLandscape = __DIR__.'/Fixtures/test_landscape.gif';
|
||||
$this->imagePortrait = __DIR__.'/Fixtures/test_portrait.gif';
|
||||
$this->image4By3 = __DIR__.'/Fixtures/test_4by3.gif';
|
||||
$this->imageCorrupted = __DIR__.'/Fixtures/test_corrupted.gif';
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Image());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Image());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidImage()
|
||||
{
|
||||
$this->validator->validate($this->image, new Image());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFileNotFound()
|
||||
{
|
||||
// Check that the logic from FileValidator still works
|
||||
$constraint = new Image(array(
|
||||
'notFoundMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('foobar', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ file }}', '"foobar"')
|
||||
->setCode(Image::NOT_FOUND_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidSize()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minWidth' => 1,
|
||||
'maxWidth' => 2,
|
||||
'minHeight' => 1,
|
||||
'maxHeight' => 2,
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testWidthTooSmall()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minWidth' => 3,
|
||||
'minWidthMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ width }}', '2')
|
||||
->setParameter('{{ min_width }}', '3')
|
||||
->setCode(Image::TOO_NARROW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testWidthTooBig()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxWidth' => 1,
|
||||
'maxWidthMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ width }}', '2')
|
||||
->setParameter('{{ max_width }}', '1')
|
||||
->setCode(Image::TOO_WIDE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testHeightTooSmall()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minHeight' => 3,
|
||||
'minHeightMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ height }}', '2')
|
||||
->setParameter('{{ min_height }}', '3')
|
||||
->setCode(Image::TOO_LOW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testHeightTooBig()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxHeight' => 1,
|
||||
'maxHeightMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ height }}', '2')
|
||||
->setParameter('{{ max_height }}', '1')
|
||||
->setCode(Image::TOO_HIGH_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testPixelsTooFew()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minPixels' => 5,
|
||||
'minPixelsMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ pixels }}', '4')
|
||||
->setParameter('{{ min_pixels }}', '5')
|
||||
->setParameter('{{ height }}', '2')
|
||||
->setParameter('{{ width }}', '2')
|
||||
->setCode(Image::TOO_FEW_PIXEL_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testPixelsTooMany()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxPixels' => 3,
|
||||
'maxPixelsMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ pixels }}', '4')
|
||||
->setParameter('{{ max_pixels }}', '3')
|
||||
->setParameter('{{ height }}', '2')
|
||||
->setParameter('{{ width }}', '2')
|
||||
->setCode(Image::TOO_MANY_PIXEL_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMinWidth()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minWidth' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMaxWidth()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxWidth' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMinHeight()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minHeight' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMaxHeight()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxHeight' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMinPixels()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minPixels' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMaxPixels()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxPixels' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
public function testRatioTooSmall()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minRatio' => 2,
|
||||
'minRatioMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ ratio }}', 1)
|
||||
->setParameter('{{ min_ratio }}', 2)
|
||||
->setCode(Image::RATIO_TOO_SMALL_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testRatioTooBig()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxRatio' => 0.5,
|
||||
'maxRatioMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ ratio }}', 1)
|
||||
->setParameter('{{ max_ratio }}', 0.5)
|
||||
->setCode(Image::RATIO_TOO_BIG_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testMaxRatioUsesTwoDecimalsOnly()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxRatio' => 1.33,
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image4By3, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMinRatio()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'minRatio' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidMaxRatio()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'maxRatio' => '1abc',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
}
|
||||
|
||||
public function testSquareNotAllowed()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'allowSquare' => false,
|
||||
'allowSquareMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ width }}', 2)
|
||||
->setParameter('{{ height }}', 2)
|
||||
->setCode(Image::SQUARE_NOT_ALLOWED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testLandscapeNotAllowed()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'allowLandscape' => false,
|
||||
'allowLandscapeMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->imageLandscape, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ width }}', 2)
|
||||
->setParameter('{{ height }}', 1)
|
||||
->setCode(Image::LANDSCAPE_NOT_ALLOWED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testPortraitNotAllowed()
|
||||
{
|
||||
$constraint = new Image(array(
|
||||
'allowPortrait' => false,
|
||||
'allowPortraitMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->imagePortrait, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ width }}', 1)
|
||||
->setParameter('{{ height }}', 2)
|
||||
->setCode(Image::PORTRAIT_NOT_ALLOWED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testCorrupted()
|
||||
{
|
||||
if (!\function_exists('imagecreatefromstring')) {
|
||||
$this->markTestSkipped('This test require GD extension');
|
||||
}
|
||||
|
||||
$constraint = new Image(array(
|
||||
'detectCorrupted' => true,
|
||||
'corruptedMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($this->image, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
|
||||
$this->validator->validate($this->imageCorrupted, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setCode(Image::CORRUPTED_IMAGE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
451
vendor/symfony/validator/Tests/Constraints/IpValidatorTest.php
vendored
Normal file
451
vendor/symfony/validator/Tests/Constraints/IpValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,451 @@
|
|||
<?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\Constraints\Ip;
|
||||
use Symfony\Component\Validator\Constraints\IpValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class IpValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new IpValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Ip());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Ip());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Ip());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
public function testInvalidValidatorVersion()
|
||||
{
|
||||
new Ip(array(
|
||||
'version' => 666,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIpsV4
|
||||
*/
|
||||
public function testValidIpsV4($ip)
|
||||
{
|
||||
$this->validator->validate($ip, new Ip(array(
|
||||
'version' => Ip::V4,
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidIpsV4()
|
||||
{
|
||||
return array(
|
||||
array('0.0.0.0'),
|
||||
array('10.0.0.0'),
|
||||
array('123.45.67.178'),
|
||||
array('172.16.0.0'),
|
||||
array('192.168.1.0'),
|
||||
array('224.0.0.1'),
|
||||
array('255.255.255.255'),
|
||||
array('127.0.0.0'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIpsV6
|
||||
*/
|
||||
public function testValidIpsV6($ip)
|
||||
{
|
||||
$this->validator->validate($ip, new Ip(array(
|
||||
'version' => Ip::V6,
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidIpsV6()
|
||||
{
|
||||
return array(
|
||||
array('2001:0db8:85a3:0000:0000:8a2e:0370:7334'),
|
||||
array('2001:0DB8:85A3:0000:0000:8A2E:0370:7334'),
|
||||
array('2001:0Db8:85a3:0000:0000:8A2e:0370:7334'),
|
||||
array('fdfe:dcba:9876:ffff:fdc6:c46b:bb8f:7d4c'),
|
||||
array('fdc6:c46b:bb8f:7d4c:fdc6:c46b:bb8f:7d4c'),
|
||||
array('fdc6:c46b:bb8f:7d4c:0000:8a2e:0370:7334'),
|
||||
array('fe80:0000:0000:0000:0202:b3ff:fe1e:8329'),
|
||||
array('fe80:0:0:0:202:b3ff:fe1e:8329'),
|
||||
array('fe80::202:b3ff:fe1e:8329'),
|
||||
array('0:0:0:0:0:0:0:0'),
|
||||
array('::'),
|
||||
array('0::'),
|
||||
array('::0'),
|
||||
array('0::0'),
|
||||
// IPv4 mapped to IPv6
|
||||
array('2001:0db8:85a3:0000:0000:8a2e:0.0.0.0'),
|
||||
array('::0.0.0.0'),
|
||||
array('::255.255.255.255'),
|
||||
array('::123.45.67.178'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIpsAll
|
||||
*/
|
||||
public function testValidIpsAll($ip)
|
||||
{
|
||||
$this->validator->validate($ip, new Ip(array(
|
||||
'version' => Ip::ALL,
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidIpsAll()
|
||||
{
|
||||
return array_merge($this->getValidIpsV4(), $this->getValidIpsV6());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIpsV4
|
||||
*/
|
||||
public function testInvalidIpsV4($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V4,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidIpsV4()
|
||||
{
|
||||
return array(
|
||||
array('0'),
|
||||
array('0.0'),
|
||||
array('0.0.0'),
|
||||
array('256.0.0.0'),
|
||||
array('0.256.0.0'),
|
||||
array('0.0.256.0'),
|
||||
array('0.0.0.256'),
|
||||
array('-1.0.0.0'),
|
||||
array('foobar'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidPrivateIpsV4
|
||||
*/
|
||||
public function testInvalidPrivateIpsV4($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V4_NO_PRIV,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidPrivateIpsV4()
|
||||
{
|
||||
return array(
|
||||
array('10.0.0.0'),
|
||||
array('172.16.0.0'),
|
||||
array('192.168.1.0'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidReservedIpsV4
|
||||
*/
|
||||
public function testInvalidReservedIpsV4($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V4_NO_RES,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidReservedIpsV4()
|
||||
{
|
||||
return array(
|
||||
array('0.0.0.0'),
|
||||
array('240.0.0.1'),
|
||||
array('255.255.255.255'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidPublicIpsV4
|
||||
*/
|
||||
public function testInvalidPublicIpsV4($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V4_ONLY_PUBLIC,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidPublicIpsV4()
|
||||
{
|
||||
return array_merge($this->getInvalidPrivateIpsV4(), $this->getInvalidReservedIpsV4());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIpsV6
|
||||
*/
|
||||
public function testInvalidIpsV6($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V6,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidIpsV6()
|
||||
{
|
||||
return array(
|
||||
array('z001:0db8:85a3:0000:0000:8a2e:0370:7334'),
|
||||
array('fe80'),
|
||||
array('fe80:8329'),
|
||||
array('fe80:::202:b3ff:fe1e:8329'),
|
||||
array('fe80::202:b3ff::fe1e:8329'),
|
||||
// IPv4 mapped to IPv6
|
||||
array('2001:0db8:85a3:0000:0000:8a2e:0370:0.0.0.0'),
|
||||
array('::0.0'),
|
||||
array('::0.0.0'),
|
||||
array('::256.0.0.0'),
|
||||
array('::0.256.0.0'),
|
||||
array('::0.0.256.0'),
|
||||
array('::0.0.0.256'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidPrivateIpsV6
|
||||
*/
|
||||
public function testInvalidPrivateIpsV6($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V6_NO_PRIV,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidPrivateIpsV6()
|
||||
{
|
||||
return array(
|
||||
array('fdfe:dcba:9876:ffff:fdc6:c46b:bb8f:7d4c'),
|
||||
array('fdc6:c46b:bb8f:7d4c:fdc6:c46b:bb8f:7d4c'),
|
||||
array('fdc6:c46b:bb8f:7d4c:0000:8a2e:0370:7334'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidReservedIpsV6
|
||||
*/
|
||||
public function testInvalidReservedIpsV6($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V6_NO_RES,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidReservedIpsV6()
|
||||
{
|
||||
// Quoting after official filter documentation:
|
||||
// "FILTER_FLAG_NO_RES_RANGE = This flag does not apply to IPv6 addresses."
|
||||
// Full description: http://php.net/manual/en/filter.filters.flags.php
|
||||
return $this->getInvalidIpsV6();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidPublicIpsV6
|
||||
*/
|
||||
public function testInvalidPublicIpsV6($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::V6_ONLY_PUBLIC,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidPublicIpsV6()
|
||||
{
|
||||
return array_merge($this->getInvalidPrivateIpsV6(), $this->getInvalidReservedIpsV6());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIpsAll
|
||||
*/
|
||||
public function testInvalidIpsAll($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::ALL,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidIpsAll()
|
||||
{
|
||||
return array_merge($this->getInvalidIpsV4(), $this->getInvalidIpsV6());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidPrivateIpsAll
|
||||
*/
|
||||
public function testInvalidPrivateIpsAll($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::ALL_NO_PRIV,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidPrivateIpsAll()
|
||||
{
|
||||
return array_merge($this->getInvalidPrivateIpsV4(), $this->getInvalidPrivateIpsV6());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidReservedIpsAll
|
||||
*/
|
||||
public function testInvalidReservedIpsAll($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::ALL_NO_RES,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidReservedIpsAll()
|
||||
{
|
||||
return array_merge($this->getInvalidReservedIpsV4(), $this->getInvalidReservedIpsV6());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidPublicIpsAll
|
||||
*/
|
||||
public function testInvalidPublicIpsAll($ip)
|
||||
{
|
||||
$constraint = new Ip(array(
|
||||
'version' => Ip::ALL_ONLY_PUBLIC,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($ip, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||
->setCode(Ip::INVALID_IP_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidPublicIpsAll()
|
||||
{
|
||||
return array_merge($this->getInvalidPublicIpsV4(), $this->getInvalidPublicIpsV6());
|
||||
}
|
||||
}
|
52
vendor/symfony/validator/Tests/Constraints/IsFalseValidatorTest.php
vendored
Normal file
52
vendor/symfony/validator/Tests/Constraints/IsFalseValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?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\Constraints\IsFalse;
|
||||
use Symfony\Component\Validator\Constraints\IsFalseValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class IsFalseValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new IsFalseValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new IsFalse());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFalseIsValid()
|
||||
{
|
||||
$this->validator->validate(false, new IsFalse());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testTrueIsInvalid()
|
||||
{
|
||||
$constraint = new IsFalse(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(true, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'true')
|
||||
->setCode(IsFalse::NOT_FALSE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
62
vendor/symfony/validator/Tests/Constraints/IsNullValidatorTest.php
vendored
Normal file
62
vendor/symfony/validator/Tests/Constraints/IsNullValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?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\Constraints\IsNull;
|
||||
use Symfony\Component\Validator\Constraints\IsNullValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class IsNullValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
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)
|
||||
->setCode(IsNull::NOT_NULL_ERROR)
|
||||
->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'),
|
||||
);
|
||||
}
|
||||
}
|
52
vendor/symfony/validator/Tests/Constraints/IsTrueValidatorTest.php
vendored
Normal file
52
vendor/symfony/validator/Tests/Constraints/IsTrueValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?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\Constraints\IsTrue;
|
||||
use Symfony\Component\Validator\Constraints\IsTrueValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class IsTrueValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new IsTrueValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new IsTrue());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testTrueIsValid()
|
||||
{
|
||||
$this->validator->validate(true, new IsTrue());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFalseIsInvalid()
|
||||
{
|
||||
$constraint = new IsTrue(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(false, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'false')
|
||||
->setCode(IsTrue::NOT_TRUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
266
vendor/symfony/validator/Tests/Constraints/IsbnValidatorTest.php
vendored
Normal file
266
vendor/symfony/validator/Tests/Constraints/IsbnValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,266 @@
|
|||
<?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\Constraints\Isbn;
|
||||
use Symfony\Component\Validator\Constraints\IsbnValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @see https://en.wikipedia.org/wiki/Isbn
|
||||
*/
|
||||
class IsbnValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new IsbnValidator();
|
||||
}
|
||||
|
||||
public function getValidIsbn10()
|
||||
{
|
||||
return array(
|
||||
array('2723442284'),
|
||||
array('2723442276'),
|
||||
array('2723455041'),
|
||||
array('2070546810'),
|
||||
array('2711858839'),
|
||||
array('2756406767'),
|
||||
array('2870971648'),
|
||||
array('226623854X'),
|
||||
array('2851806424'),
|
||||
array('0321812700'),
|
||||
array('0-45122-5244'),
|
||||
array('0-4712-92311'),
|
||||
array('0-9752298-0-X'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getInvalidIsbn10()
|
||||
{
|
||||
return array(
|
||||
array('27234422841', Isbn::TOO_LONG_ERROR),
|
||||
array('272344228', Isbn::TOO_SHORT_ERROR),
|
||||
array('0-4712-9231', Isbn::TOO_SHORT_ERROR),
|
||||
array('1234567890', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('0987656789', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('7-35622-5444', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('0-4X19-92611', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('0_45122_5244', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
array('2870#971#648', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
array('0-9752298-0-x', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
array('1A34567890', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
// chr(1) evaluates to 0
|
||||
// 2070546810 is valid
|
||||
array('2'.\chr(1).'70546810', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
);
|
||||
}
|
||||
|
||||
public function getValidIsbn13()
|
||||
{
|
||||
return array(
|
||||
array('978-2723442282'),
|
||||
array('978-2723442275'),
|
||||
array('978-2723455046'),
|
||||
array('978-2070546817'),
|
||||
array('978-2711858835'),
|
||||
array('978-2756406763'),
|
||||
array('978-2870971642'),
|
||||
array('978-2266238540'),
|
||||
array('978-2851806420'),
|
||||
array('978-0321812704'),
|
||||
array('978-0451225245'),
|
||||
array('978-0471292319'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getInvalidIsbn13()
|
||||
{
|
||||
return array(
|
||||
array('978-27234422821', Isbn::TOO_LONG_ERROR),
|
||||
array('978-272344228', Isbn::TOO_SHORT_ERROR),
|
||||
array('978-2723442-82', Isbn::TOO_SHORT_ERROR),
|
||||
array('978-2723442281', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('978-0321513774', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('979-0431225385', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('980-0474292319', Isbn::CHECKSUM_FAILED_ERROR),
|
||||
array('0-4X19-92619812', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
array('978_2723442282', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
array('978#2723442282', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
array('978-272C442282', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
// chr(1) evaluates to 0
|
||||
// 978-2070546817 is valid
|
||||
array('978-2'.\chr(1).'70546817', Isbn::INVALID_CHARACTERS_ERROR),
|
||||
);
|
||||
}
|
||||
|
||||
public function getValidIsbn()
|
||||
{
|
||||
return array_merge(
|
||||
$this->getValidIsbn10(),
|
||||
$this->getValidIsbn13()
|
||||
);
|
||||
}
|
||||
|
||||
public function getInvalidIsbn()
|
||||
{
|
||||
return array_merge(
|
||||
$this->getInvalidIsbn10(),
|
||||
$this->getInvalidIsbn13()
|
||||
);
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$constraint = new Isbn(true);
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$constraint = new Isbn(true);
|
||||
|
||||
$this->validator->validate('', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$constraint = new Isbn(true);
|
||||
|
||||
$this->validator->validate(new \stdClass(), $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIsbn10
|
||||
*/
|
||||
public function testValidIsbn10($isbn)
|
||||
{
|
||||
$constraint = new Isbn(array(
|
||||
'type' => 'isbn10',
|
||||
));
|
||||
|
||||
$this->validator->validate($isbn, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIsbn10
|
||||
*/
|
||||
public function testInvalidIsbn10($isbn, $code)
|
||||
{
|
||||
$constraint = new Isbn(array(
|
||||
'type' => 'isbn10',
|
||||
'isbn10Message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($isbn, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$isbn.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIsbn13
|
||||
*/
|
||||
public function testValidIsbn13($isbn)
|
||||
{
|
||||
$constraint = new Isbn(array('type' => 'isbn13'));
|
||||
|
||||
$this->validator->validate($isbn, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIsbn13
|
||||
*/
|
||||
public function testInvalidIsbn13($isbn, $code)
|
||||
{
|
||||
$constraint = new Isbn(array(
|
||||
'type' => 'isbn13',
|
||||
'isbn13Message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($isbn, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$isbn.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIsbn
|
||||
*/
|
||||
public function testValidIsbnAny($isbn)
|
||||
{
|
||||
$constraint = new Isbn();
|
||||
|
||||
$this->validator->validate($isbn, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIsbn10
|
||||
*/
|
||||
public function testInvalidIsbnAnyIsbn10($isbn, $code)
|
||||
{
|
||||
$constraint = new Isbn(array(
|
||||
'bothIsbnMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($isbn, $constraint);
|
||||
|
||||
// Too long for an ISBN-10, but not long enough for an ISBN-13
|
||||
if (Isbn::TOO_LONG_ERROR === $code) {
|
||||
$code = Isbn::TYPE_NOT_RECOGNIZED_ERROR;
|
||||
}
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$isbn.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIsbn13
|
||||
*/
|
||||
public function testInvalidIsbnAnyIsbn13($isbn, $code)
|
||||
{
|
||||
$constraint = new Isbn(array(
|
||||
'bothIsbnMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($isbn, $constraint);
|
||||
|
||||
// Too short for an ISBN-13, but not short enough for an ISBN-10
|
||||
if (Isbn::TOO_SHORT_ERROR === $code) {
|
||||
$code = Isbn::TYPE_NOT_RECOGNIZED_ERROR;
|
||||
}
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$isbn.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
182
vendor/symfony/validator/Tests/Constraints/IssnValidatorTest.php
vendored
Normal file
182
vendor/symfony/validator/Tests/Constraints/IssnValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,182 @@
|
|||
<?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\Constraints\Issn;
|
||||
use Symfony\Component\Validator\Constraints\IssnValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @see https://en.wikipedia.org/wiki/Issn
|
||||
*/
|
||||
class IssnValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new IssnValidator();
|
||||
}
|
||||
|
||||
public function getValidLowerCasedIssn()
|
||||
{
|
||||
return array(
|
||||
array('2162-321x'),
|
||||
array('2160-200x'),
|
||||
array('1537-453x'),
|
||||
array('1937-710x'),
|
||||
array('0002-922x'),
|
||||
array('1553-345x'),
|
||||
array('1553-619x'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getValidNonHyphenatedIssn()
|
||||
{
|
||||
return array(
|
||||
array('2162321X'),
|
||||
array('01896016'),
|
||||
array('15744647'),
|
||||
array('14350645'),
|
||||
array('07174055'),
|
||||
array('20905076'),
|
||||
array('14401592'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFullValidIssn()
|
||||
{
|
||||
return array(
|
||||
array('1550-7416'),
|
||||
array('1539-8560'),
|
||||
array('2156-5376'),
|
||||
array('1119-023X'),
|
||||
array('1684-5315'),
|
||||
array('1996-0786'),
|
||||
array('1684-5374'),
|
||||
array('1996-0794'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getValidIssn()
|
||||
{
|
||||
return array_merge(
|
||||
$this->getValidLowerCasedIssn(),
|
||||
$this->getValidNonHyphenatedIssn(),
|
||||
$this->getFullValidIssn()
|
||||
);
|
||||
}
|
||||
|
||||
public function getInvalidIssn()
|
||||
{
|
||||
return array(
|
||||
array(0, Issn::TOO_SHORT_ERROR),
|
||||
array('1539', Issn::TOO_SHORT_ERROR),
|
||||
array('2156-537A', Issn::INVALID_CHARACTERS_ERROR),
|
||||
array('1119-0231', Issn::CHECKSUM_FAILED_ERROR),
|
||||
array('1684-5312', Issn::CHECKSUM_FAILED_ERROR),
|
||||
array('1996-0783', Issn::CHECKSUM_FAILED_ERROR),
|
||||
array('1684-537X', Issn::CHECKSUM_FAILED_ERROR),
|
||||
array('1996-0795', Issn::CHECKSUM_FAILED_ERROR),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$constraint = new Issn();
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$constraint = new Issn();
|
||||
|
||||
$this->validator->validate('', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$constraint = new Issn();
|
||||
$this->validator->validate(new \stdClass(), $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidLowerCasedIssn
|
||||
*/
|
||||
public function testCaseSensitiveIssns($issn)
|
||||
{
|
||||
$constraint = new Issn(array(
|
||||
'caseSensitive' => true,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($issn, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||
->setCode(Issn::INVALID_CASE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidNonHyphenatedIssn
|
||||
*/
|
||||
public function testRequireHyphenIssns($issn)
|
||||
{
|
||||
$constraint = new Issn(array(
|
||||
'requireHyphen' => true,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($issn, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||
->setCode(Issn::MISSING_HYPHEN_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidIssn
|
||||
*/
|
||||
public function testValidIssn($issn)
|
||||
{
|
||||
$constraint = new Issn();
|
||||
|
||||
$this->validator->validate($issn, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidIssn
|
||||
*/
|
||||
public function testInvalidIssn($issn, $code)
|
||||
{
|
||||
$constraint = new Issn(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($issn, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
105
vendor/symfony/validator/Tests/Constraints/LanguageValidatorTest.php
vendored
Normal file
105
vendor/symfony/validator/Tests/Constraints/LanguageValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?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\Intl\Util\IntlTestHelper;
|
||||
use Symfony\Component\Validator\Constraints\Language;
|
||||
use Symfony\Component\Validator\Constraints\LanguageValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class LanguageValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new LanguageValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Language());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Language());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Language());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidLanguages
|
||||
*/
|
||||
public function testValidLanguages($language)
|
||||
{
|
||||
$this->validator->validate($language, new Language());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidLanguages()
|
||||
{
|
||||
return array(
|
||||
array('en'),
|
||||
array('en_US'),
|
||||
array('my'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidLanguages
|
||||
*/
|
||||
public function testInvalidLanguages($language)
|
||||
{
|
||||
$constraint = new Language(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($language, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$language.'"')
|
||||
->setCode(Language::NO_SUCH_LANGUAGE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidLanguages()
|
||||
{
|
||||
return array(
|
||||
array('EN'),
|
||||
array('foobar'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testValidateUsingCountrySpecificLocale()
|
||||
{
|
||||
IntlTestHelper::requireFullIntl($this, false);
|
||||
|
||||
\Locale::setDefault('fr_FR');
|
||||
$existingLanguage = 'en';
|
||||
|
||||
$this->validator->validate($existingLanguage, new Language(array(
|
||||
'message' => 'aMessage',
|
||||
)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
}
|
247
vendor/symfony/validator/Tests/Constraints/LengthValidatorTest.php
vendored
Normal file
247
vendor/symfony/validator/Tests/Constraints/LengthValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,247 @@
|
|||
<?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\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\LengthValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class LengthValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new LengthValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Length(6));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Length(6));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Length(5));
|
||||
}
|
||||
|
||||
public function getThreeOrLessCharacters()
|
||||
{
|
||||
return array(
|
||||
array(12),
|
||||
array('12'),
|
||||
array('üü'),
|
||||
array('éé'),
|
||||
array(123),
|
||||
array('123'),
|
||||
array('üüü'),
|
||||
array('ééé'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFourCharacters()
|
||||
{
|
||||
return array(
|
||||
array(1234),
|
||||
array('1234'),
|
||||
array('üüüü'),
|
||||
array('éééé'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFiveOrMoreCharacters()
|
||||
{
|
||||
return array(
|
||||
array(12345),
|
||||
array('12345'),
|
||||
array('üüüüü'),
|
||||
array('ééééé'),
|
||||
array(123456),
|
||||
array('123456'),
|
||||
array('üüüüüü'),
|
||||
array('éééééé'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getOneCharset()
|
||||
{
|
||||
return array(
|
||||
array('é', 'utf8', true),
|
||||
array("\xE9", 'CP1252', true),
|
||||
array("\xE9", 'XXX', false),
|
||||
array("\xE9", 'utf8', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFiveOrMoreCharacters
|
||||
*/
|
||||
public function testValidValuesMin($value)
|
||||
{
|
||||
$constraint = new Length(array('min' => 5));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getThreeOrLessCharacters
|
||||
*/
|
||||
public function testValidValuesMax($value)
|
||||
{
|
||||
$constraint = new Length(array('max' => 3));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFourCharacters
|
||||
*/
|
||||
public function testValidValuesExact($value)
|
||||
{
|
||||
$constraint = new Length(4);
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getThreeOrLessCharacters
|
||||
*/
|
||||
public function testInvalidValuesMin($value)
|
||||
{
|
||||
$constraint = new Length(array(
|
||||
'min' => 4,
|
||||
'minMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$value.'"')
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Length::TOO_SHORT_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFiveOrMoreCharacters
|
||||
*/
|
||||
public function testInvalidValuesMax($value)
|
||||
{
|
||||
$constraint = new Length(array(
|
||||
'max' => 4,
|
||||
'maxMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$value.'"')
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Length::TOO_LONG_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getThreeOrLessCharacters
|
||||
*/
|
||||
public function testInvalidValuesExactLessThanFour($value)
|
||||
{
|
||||
$constraint = new Length(array(
|
||||
'min' => 4,
|
||||
'max' => 4,
|
||||
'exactMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$value.'"')
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Length::TOO_SHORT_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFiveOrMoreCharacters
|
||||
*/
|
||||
public function testInvalidValuesExactMoreThanFour($value)
|
||||
{
|
||||
$constraint = new Length(array(
|
||||
'min' => 4,
|
||||
'max' => 4,
|
||||
'exactMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$value.'"')
|
||||
->setParameter('{{ limit }}', 4)
|
||||
->setInvalidValue($value)
|
||||
->setPlural(4)
|
||||
->setCode(Length::TOO_LONG_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getOneCharset
|
||||
*/
|
||||
public function testOneCharset($value, $charset, $isValid)
|
||||
{
|
||||
$constraint = new Length(array(
|
||||
'min' => 1,
|
||||
'max' => 1,
|
||||
'charset' => $charset,
|
||||
'charsetMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
if ($isValid) {
|
||||
$this->assertNoViolation();
|
||||
} else {
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$value.'"')
|
||||
->setParameter('{{ charset }}', $charset)
|
||||
->setInvalidValue($value)
|
||||
->setCode(Length::INVALID_CHARACTERS_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstraintGetDefaultOption()
|
||||
{
|
||||
$constraint = new Length(5);
|
||||
|
||||
$this->assertEquals(5, $constraint->min);
|
||||
$this->assertEquals(5, $constraint->max);
|
||||
}
|
||||
}
|
84
vendor/symfony/validator/Tests/Constraints/LessThanOrEqualValidatorTest.php
vendored
Normal file
84
vendor/symfony/validator/Tests/Constraints/LessThanOrEqualValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?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\Constraints\LessThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\LessThanOrEqualValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new LessThanOrEqualValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new LessThanOrEqual($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return LessThanOrEqual::TOO_HIGH_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, 2),
|
||||
array(1, 1),
|
||||
array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')),
|
||||
array(new \DateTime('2000-01-01'), new \DateTime('2020-01-01')),
|
||||
array(new \DateTime('2000-01-01'), '2000-01-01'),
|
||||
array(new \DateTime('2000-01-01'), '2020-01-01'),
|
||||
array(new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'),
|
||||
array(new \DateTime('2000-01-01 UTC'), '2020-01-01 UTC'),
|
||||
array(new ComparisonTest_Class(4), new ComparisonTest_Class(5)),
|
||||
array(new ComparisonTest_Class(5), new ComparisonTest_Class(5)),
|
||||
array('a', 'a'),
|
||||
array('a', 'z'),
|
||||
array(null, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(4),
|
||||
array(5),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(2, '2', 1, '1', 'integer'),
|
||||
array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2010-01-01 UTC'), 'Jan 1, 2010, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(4), '4', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
array('c', '"c"', 'b', '"b"', 'string'),
|
||||
);
|
||||
}
|
||||
}
|
82
vendor/symfony/validator/Tests/Constraints/LessThanValidatorTest.php
vendored
Normal file
82
vendor/symfony/validator/Tests/Constraints/LessThanValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?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\Constraints\LessThan;
|
||||
use Symfony\Component\Validator\Constraints\LessThanValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class LessThanValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new LessThanValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new LessThan($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return LessThan::TOO_HIGH_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, 2),
|
||||
array(new \DateTime('2000-01-01'), new \DateTime('2010-01-01')),
|
||||
array(new \DateTime('2000-01-01'), '2010-01-01'),
|
||||
array(new \DateTime('2000-01-01 UTC'), '2010-01-01 UTC'),
|
||||
array(new ComparisonTest_Class(4), new ComparisonTest_Class(5)),
|
||||
array('22', '333'),
|
||||
array(null, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(4),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(3, '3', 2, '2', 'integer'),
|
||||
array(2, '2', 2, '2', 'integer'),
|
||||
array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2010-01-01 UTC'), 'Jan 1, 2010, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000-01-01 UTC'), 'Jan 1, 2000, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
array(new ComparisonTest_Class(6), '6', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
array('333', '"333"', '22', '"22"', 'string'),
|
||||
);
|
||||
}
|
||||
}
|
93
vendor/symfony/validator/Tests/Constraints/LocaleValidatorTest.php
vendored
Normal file
93
vendor/symfony/validator/Tests/Constraints/LocaleValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?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\Constraints\Locale;
|
||||
use Symfony\Component\Validator\Constraints\LocaleValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class LocaleValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new LocaleValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Locale());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Locale());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Locale());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidLocales
|
||||
*/
|
||||
public function testValidLocales($locale)
|
||||
{
|
||||
$this->validator->validate($locale, new Locale());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidLocales()
|
||||
{
|
||||
return array(
|
||||
array('en'),
|
||||
array('en_US'),
|
||||
array('pt'),
|
||||
array('pt_PT'),
|
||||
array('zh_Hans'),
|
||||
array('fil_PH'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidLocales
|
||||
*/
|
||||
public function testInvalidLocales($locale)
|
||||
{
|
||||
$constraint = new Locale(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($locale, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$locale.'"')
|
||||
->setCode(Locale::NO_SUCH_LOCALE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidLocales()
|
||||
{
|
||||
return array(
|
||||
array('EN'),
|
||||
array('foobar'),
|
||||
);
|
||||
}
|
||||
}
|
122
vendor/symfony/validator/Tests/Constraints/LuhnValidatorTest.php
vendored
Normal file
122
vendor/symfony/validator/Tests/Constraints/LuhnValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
<?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\Constraints\Luhn;
|
||||
use Symfony\Component\Validator\Constraints\LuhnValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class LuhnValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new LuhnValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Luhn());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Luhn());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidNumbers
|
||||
*/
|
||||
public function testValidNumbers($number)
|
||||
{
|
||||
$this->validator->validate($number, new Luhn());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidNumbers()
|
||||
{
|
||||
return array(
|
||||
array('42424242424242424242'),
|
||||
array('378282246310005'),
|
||||
array('371449635398431'),
|
||||
array('378734493671000'),
|
||||
array('5610591081018250'),
|
||||
array('30569309025904'),
|
||||
array('38520000023237'),
|
||||
array('6011111111111117'),
|
||||
array('6011000990139424'),
|
||||
array('3530111333300000'),
|
||||
array('3566002020360505'),
|
||||
array('5555555555554444'),
|
||||
array('5105105105105100'),
|
||||
array('4111111111111111'),
|
||||
array('4012888888881881'),
|
||||
array('4222222222222'),
|
||||
array('5019717010103742'),
|
||||
array('6331101999990016'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidNumbers
|
||||
*/
|
||||
public function testInvalidNumbers($number, $code)
|
||||
{
|
||||
$constraint = new Luhn(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($number, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$number.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidNumbers()
|
||||
{
|
||||
return array(
|
||||
array('1234567812345678', Luhn::CHECKSUM_FAILED_ERROR),
|
||||
array('4222222222222222', Luhn::CHECKSUM_FAILED_ERROR),
|
||||
array('0000000000000000', Luhn::CHECKSUM_FAILED_ERROR),
|
||||
array('000000!000000000', Luhn::INVALID_CHARACTERS_ERROR),
|
||||
array('42-22222222222222', Luhn::INVALID_CHARACTERS_ERROR),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
* @dataProvider getInvalidTypes
|
||||
*/
|
||||
public function testInvalidTypes($number)
|
||||
{
|
||||
$constraint = new Luhn();
|
||||
|
||||
$this->validator->validate($number, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidTypes()
|
||||
{
|
||||
return array(
|
||||
array(0),
|
||||
array(123),
|
||||
array(42424242424242424242),
|
||||
array(378282246310005),
|
||||
array(371449635398431),
|
||||
);
|
||||
}
|
||||
}
|
101
vendor/symfony/validator/Tests/Constraints/NotBlankValidatorTest.php
vendored
Normal file
101
vendor/symfony/validator/Tests/Constraints/NotBlankValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?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\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\NotBlankValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class NotBlankValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new NotBlankValidator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidValues
|
||||
*/
|
||||
public function testValidValues($value)
|
||||
{
|
||||
$this->validator->validate($value, new NotBlank());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidValues()
|
||||
{
|
||||
return array(
|
||||
array('foobar'),
|
||||
array(0),
|
||||
array(0.0),
|
||||
array('0'),
|
||||
array(1234),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNullIsInvalid()
|
||||
{
|
||||
$constraint = new NotBlank(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'null')
|
||||
->setCode(NotBlank::IS_BLANK_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testBlankIsInvalid()
|
||||
{
|
||||
$constraint = new NotBlank(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '""')
|
||||
->setCode(NotBlank::IS_BLANK_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testFalseIsInvalid()
|
||||
{
|
||||
$constraint = new NotBlank(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(false, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'false')
|
||||
->setCode(NotBlank::IS_BLANK_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testEmptyArrayIsInvalid()
|
||||
{
|
||||
$constraint = new NotBlank(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(array(), $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'array')
|
||||
->setCode(NotBlank::IS_BLANK_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
78
vendor/symfony/validator/Tests/Constraints/NotEqualToValidatorTest.php
vendored
Normal file
78
vendor/symfony/validator/Tests/Constraints/NotEqualToValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?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\Constraints\NotEqualTo;
|
||||
use Symfony\Component\Validator\Constraints\NotEqualToValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new NotEqualToValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new NotEqualTo($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return NotEqualTo::IS_EQUAL_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, 2),
|
||||
array('22', '333'),
|
||||
array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01')),
|
||||
array(new \DateTime('2001-01-01'), '2000-01-01'),
|
||||
array(new \DateTime('2001-01-01 UTC'), '2000-01-01 UTC'),
|
||||
array(new ComparisonTest_Class(6), new ComparisonTest_Class(5)),
|
||||
array(null, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(0),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(3, '3', 3, '3', 'integer'),
|
||||
array('2', '"2"', 2, '2', 'integer'),
|
||||
array('a', '"a"', 'a', '"a"', 'string'),
|
||||
array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new \DateTime('2000-01-01 UTC'), 'Jan 1, 2000, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
);
|
||||
}
|
||||
}
|
96
vendor/symfony/validator/Tests/Constraints/NotIdenticalToValidatorTest.php
vendored
Normal file
96
vendor/symfony/validator/Tests/Constraints/NotIdenticalToValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?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\Constraints\NotIdenticalTo;
|
||||
use Symfony\Component\Validator\Constraints\NotIdenticalToValidator;
|
||||
|
||||
/**
|
||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||
*/
|
||||
class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new NotIdenticalToValidator();
|
||||
}
|
||||
|
||||
protected function createConstraint(array $options = null)
|
||||
{
|
||||
return new NotIdenticalTo($options);
|
||||
}
|
||||
|
||||
protected function getErrorCode()
|
||||
{
|
||||
return NotIdenticalTo::IS_IDENTICAL_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisons()
|
||||
{
|
||||
return array(
|
||||
array(1, 2),
|
||||
array('2', 2),
|
||||
array('22', '333'),
|
||||
array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01')),
|
||||
array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')),
|
||||
array(new \DateTime('2001-01-01'), '2000-01-01'),
|
||||
array(new \DateTime('2000-01-01'), '2000-01-01'),
|
||||
array(new \DateTime('2001-01-01'), '2000-01-01'),
|
||||
array(new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'),
|
||||
array(null, 1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideValidComparisonsToPropertyPath()
|
||||
{
|
||||
return array(
|
||||
array(0),
|
||||
);
|
||||
}
|
||||
|
||||
public function provideAllInvalidComparisons()
|
||||
{
|
||||
$this->setDefaultTimezone('UTC');
|
||||
|
||||
// Don't call addPhp5Dot5Comparisons() automatically, as it does
|
||||
// not take care of identical objects
|
||||
$comparisons = $this->provideInvalidComparisons();
|
||||
|
||||
$this->restoreDefaultTimezone();
|
||||
|
||||
return $comparisons;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function provideInvalidComparisons()
|
||||
{
|
||||
$date = new \DateTime('2000-01-01');
|
||||
$object = new ComparisonTest_Class(2);
|
||||
|
||||
$comparisons = array(
|
||||
array(3, '3', 3, '3', 'integer'),
|
||||
array('a', '"a"', 'a', '"a"', 'string'),
|
||||
array($date, 'Jan 1, 2000, 12:00 AM', $date, 'Jan 1, 2000, 12:00 AM', 'DateTime'),
|
||||
array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
);
|
||||
|
||||
return $comparisons;
|
||||
}
|
||||
}
|
58
vendor/symfony/validator/Tests/Constraints/NotNullValidatorTest.php
vendored
Normal file
58
vendor/symfony/validator/Tests/Constraints/NotNullValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?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\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Constraints\NotNullValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class NotNullValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new NotNullValidator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidValues
|
||||
*/
|
||||
public function testValidValues($value)
|
||||
{
|
||||
$this->validator->validate($value, new NotNull());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidValues()
|
||||
{
|
||||
return array(
|
||||
array(0),
|
||||
array(false),
|
||||
array(true),
|
||||
array(''),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNullIsInvalid()
|
||||
{
|
||||
$constraint = new NotNull(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'null')
|
||||
->setCode(NotNull::IS_NULL_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
392
vendor/symfony/validator/Tests/Constraints/RangeValidatorTest.php
vendored
Normal file
392
vendor/symfony/validator/Tests/Constraints/RangeValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,392 @@
|
|||
<?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\Intl\Util\IntlTestHelper;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Constraints\RangeValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class RangeValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new RangeValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Range(array('min' => 10, 'max' => 20)));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getTenToTwenty()
|
||||
{
|
||||
return array(
|
||||
array(10.00001),
|
||||
array(19.99999),
|
||||
array('10.00001'),
|
||||
array('19.99999'),
|
||||
array(10),
|
||||
array(20),
|
||||
array(10.0),
|
||||
array(20.0),
|
||||
);
|
||||
}
|
||||
|
||||
public function getLessThanTen()
|
||||
{
|
||||
return array(
|
||||
array(9.99999, '9.99999'),
|
||||
array('9.99999', '"9.99999"'),
|
||||
array(5, '5'),
|
||||
array(1.0, '1.0'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getMoreThanTwenty()
|
||||
{
|
||||
return array(
|
||||
array(20.000001, '20.000001'),
|
||||
array('20.000001', '"20.000001"'),
|
||||
array(21, '21'),
|
||||
array(30.0, '30.0'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTenToTwenty
|
||||
*/
|
||||
public function testValidValuesMin($value)
|
||||
{
|
||||
$constraint = new Range(array('min' => 10));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTenToTwenty
|
||||
*/
|
||||
public function testValidValuesMax($value)
|
||||
{
|
||||
$constraint = new Range(array('max' => 20));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTenToTwenty
|
||||
*/
|
||||
public function testValidValuesMinMax($value)
|
||||
{
|
||||
$constraint = new Range(array('min' => 10, 'max' => 20));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLessThanTen
|
||||
*/
|
||||
public function testInvalidValuesMin($value, $formattedValue)
|
||||
{
|
||||
$constraint = new Range(array(
|
||||
'min' => 10,
|
||||
'minMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', $formattedValue)
|
||||
->setParameter('{{ limit }}', 10)
|
||||
->setCode(Range::TOO_LOW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getMoreThanTwenty
|
||||
*/
|
||||
public function testInvalidValuesMax($value, $formattedValue)
|
||||
{
|
||||
$constraint = new Range(array(
|
||||
'max' => 20,
|
||||
'maxMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', $formattedValue)
|
||||
->setParameter('{{ limit }}', 20)
|
||||
->setCode(Range::TOO_HIGH_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getMoreThanTwenty
|
||||
*/
|
||||
public function testInvalidValuesCombinedMax($value, $formattedValue)
|
||||
{
|
||||
$constraint = new Range(array(
|
||||
'min' => 10,
|
||||
'max' => 20,
|
||||
'minMessage' => 'myMinMessage',
|
||||
'maxMessage' => 'myMaxMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMaxMessage')
|
||||
->setParameter('{{ value }}', $formattedValue)
|
||||
->setParameter('{{ limit }}', 20)
|
||||
->setCode(Range::TOO_HIGH_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLessThanTen
|
||||
*/
|
||||
public function testInvalidValuesCombinedMin($value, $formattedValue)
|
||||
{
|
||||
$constraint = new Range(array(
|
||||
'min' => 10,
|
||||
'max' => 20,
|
||||
'minMessage' => 'myMinMessage',
|
||||
'maxMessage' => 'myMaxMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMinMessage')
|
||||
->setParameter('{{ value }}', $formattedValue)
|
||||
->setParameter('{{ limit }}', 10)
|
||||
->setCode(Range::TOO_LOW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getTenthToTwentiethMarch2014()
|
||||
{
|
||||
// The provider runs before setUp(), so we need to manually fix
|
||||
// the default timezone
|
||||
$this->setDefaultTimezone('UTC');
|
||||
|
||||
$tests = array(
|
||||
array(new \DateTime('March 10, 2014')),
|
||||
array(new \DateTime('March 15, 2014')),
|
||||
array(new \DateTime('March 20, 2014')),
|
||||
);
|
||||
|
||||
$tests[] = array(new \DateTimeImmutable('March 10, 2014'));
|
||||
$tests[] = array(new \DateTimeImmutable('March 15, 2014'));
|
||||
$tests[] = array(new \DateTimeImmutable('March 20, 2014'));
|
||||
|
||||
$this->restoreDefaultTimezone();
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
public function getSoonerThanTenthMarch2014()
|
||||
{
|
||||
// The provider runs before setUp(), so we need to manually fix
|
||||
// the default timezone
|
||||
$this->setDefaultTimezone('UTC');
|
||||
|
||||
$tests = array(
|
||||
array(new \DateTime('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'),
|
||||
array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'),
|
||||
);
|
||||
|
||||
$tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM');
|
||||
$tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM');
|
||||
|
||||
$this->restoreDefaultTimezone();
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
public function getLaterThanTwentiethMarch2014()
|
||||
{
|
||||
// The provider runs before setUp(), so we need to manually fix
|
||||
// the default timezone
|
||||
$this->setDefaultTimezone('UTC');
|
||||
|
||||
$tests = array(
|
||||
array(new \DateTime('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'),
|
||||
array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'),
|
||||
);
|
||||
|
||||
$tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM');
|
||||
$tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM');
|
||||
|
||||
$this->restoreDefaultTimezone();
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTenthToTwentiethMarch2014
|
||||
*/
|
||||
public function testValidDatesMin($value)
|
||||
{
|
||||
$constraint = new Range(array('min' => 'March 10, 2014'));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTenthToTwentiethMarch2014
|
||||
*/
|
||||
public function testValidDatesMax($value)
|
||||
{
|
||||
$constraint = new Range(array('max' => 'March 20, 2014'));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTenthToTwentiethMarch2014
|
||||
*/
|
||||
public function testValidDatesMinMax($value)
|
||||
{
|
||||
$constraint = new Range(array('min' => 'March 10, 2014', 'max' => 'March 20, 2014'));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSoonerThanTenthMarch2014
|
||||
*/
|
||||
public function testInvalidDatesMin($value, $dateTimeAsString)
|
||||
{
|
||||
// Conversion of dates to string differs between ICU versions
|
||||
// Make sure we have the correct version loaded
|
||||
IntlTestHelper::requireIntl($this, '57.1');
|
||||
|
||||
$constraint = new Range(array(
|
||||
'min' => 'March 10, 2014',
|
||||
'minMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', $dateTimeAsString)
|
||||
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
|
||||
->setCode(Range::TOO_LOW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLaterThanTwentiethMarch2014
|
||||
*/
|
||||
public function testInvalidDatesMax($value, $dateTimeAsString)
|
||||
{
|
||||
// Conversion of dates to string differs between ICU versions
|
||||
// Make sure we have the correct version loaded
|
||||
IntlTestHelper::requireIntl($this, '57.1');
|
||||
|
||||
$constraint = new Range(array(
|
||||
'max' => 'March 20, 2014',
|
||||
'maxMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', $dateTimeAsString)
|
||||
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
|
||||
->setCode(Range::TOO_HIGH_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLaterThanTwentiethMarch2014
|
||||
*/
|
||||
public function testInvalidDatesCombinedMax($value, $dateTimeAsString)
|
||||
{
|
||||
// Conversion of dates to string differs between ICU versions
|
||||
// Make sure we have the correct version loaded
|
||||
IntlTestHelper::requireIntl($this, '57.1');
|
||||
|
||||
$constraint = new Range(array(
|
||||
'min' => 'March 10, 2014',
|
||||
'max' => 'March 20, 2014',
|
||||
'minMessage' => 'myMinMessage',
|
||||
'maxMessage' => 'myMaxMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMaxMessage')
|
||||
->setParameter('{{ value }}', $dateTimeAsString)
|
||||
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
|
||||
->setCode(Range::TOO_HIGH_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSoonerThanTenthMarch2014
|
||||
*/
|
||||
public function testInvalidDatesCombinedMin($value, $dateTimeAsString)
|
||||
{
|
||||
// Conversion of dates to string differs between ICU versions
|
||||
// Make sure we have the correct version loaded
|
||||
IntlTestHelper::requireIntl($this, '57.1');
|
||||
|
||||
$constraint = new Range(array(
|
||||
'min' => 'March 10, 2014',
|
||||
'max' => 'March 20, 2014',
|
||||
'minMessage' => 'myMinMessage',
|
||||
'maxMessage' => 'myMaxMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMinMessage')
|
||||
->setParameter('{{ value }}', $dateTimeAsString)
|
||||
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
|
||||
->setCode(Range::TOO_LOW_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
{
|
||||
return array(
|
||||
array(9.999999),
|
||||
array(20.000001),
|
||||
array('9.999999'),
|
||||
array('20.000001'),
|
||||
array(new \stdClass()),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNonNumeric()
|
||||
{
|
||||
$this->validator->validate('abcd', new Range(array(
|
||||
'min' => 10,
|
||||
'max' => 20,
|
||||
'invalidMessage' => 'myMessage',
|
||||
)));
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"abcd"')
|
||||
->setCode(Range::INVALID_CHARACTERS_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
88
vendor/symfony/validator/Tests/Constraints/RegexTest.php
vendored
Normal file
88
vendor/symfony/validator/Tests/Constraints/RegexTest.php
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?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 PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\Regex;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class RegexTest extends TestCase
|
||||
{
|
||||
public function testConstraintGetDefaultOption()
|
||||
{
|
||||
$constraint = new Regex('/^[0-9]+$/');
|
||||
|
||||
$this->assertSame('/^[0-9]+$/', $constraint->pattern);
|
||||
}
|
||||
|
||||
public function provideHtmlPatterns()
|
||||
{
|
||||
return array(
|
||||
// HTML5 wraps the pattern in ^(?:pattern)$
|
||||
array('/^[0-9]+$/', '[0-9]+'),
|
||||
array('/[0-9]+$/', '.*[0-9]+'),
|
||||
array('/^[0-9]+/', '[0-9]+.*'),
|
||||
array('/[0-9]+/', '.*[0-9]+.*'),
|
||||
// We need a smart way to allow matching of patterns that contain
|
||||
// ^ and $ at various sub-clauses of an or-clause
|
||||
// .*(pattern).* seems to work correctly
|
||||
array('/[0-9]$|[a-z]+/', '.*([0-9]$|[a-z]+).*'),
|
||||
array('/[0-9]$|^[a-z]+/', '.*([0-9]$|^[a-z]+).*'),
|
||||
array('/^[0-9]|[a-z]+$/', '.*(^[0-9]|[a-z]+$).*'),
|
||||
// Unescape escaped delimiters
|
||||
array('/^[0-9]+\/$/', '[0-9]+/'),
|
||||
array('#^[0-9]+\#$#', '[0-9]+#'),
|
||||
// Cannot be converted
|
||||
array('/^[0-9]+$/i', null),
|
||||
|
||||
// Inverse matches are simple, just wrap in
|
||||
// ((?!pattern).)*
|
||||
array('/^[0-9]+$/', '((?!^[0-9]+$).)*', false),
|
||||
array('/[0-9]+$/', '((?![0-9]+$).)*', false),
|
||||
array('/^[0-9]+/', '((?!^[0-9]+).)*', false),
|
||||
array('/[0-9]+/', '((?![0-9]+).)*', false),
|
||||
array('/[0-9]$|[a-z]+/', '((?![0-9]$|[a-z]+).)*', false),
|
||||
array('/[0-9]$|^[a-z]+/', '((?![0-9]$|^[a-z]+).)*', false),
|
||||
array('/^[0-9]|[a-z]+$/', '((?!^[0-9]|[a-z]+$).)*', false),
|
||||
array('/^[0-9]+\/$/', '((?!^[0-9]+/$).)*', false),
|
||||
array('#^[0-9]+\#$#', '((?!^[0-9]+#$).)*', false),
|
||||
array('/^[0-9]+$/i', null, false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideHtmlPatterns
|
||||
*/
|
||||
public function testGetHtmlPattern($pattern, $htmlPattern, $match = true)
|
||||
{
|
||||
$constraint = new Regex(array(
|
||||
'pattern' => $pattern,
|
||||
'match' => $match,
|
||||
));
|
||||
|
||||
$this->assertSame($pattern, $constraint->pattern);
|
||||
$this->assertSame($htmlPattern, $constraint->getHtmlPattern());
|
||||
}
|
||||
|
||||
public function testGetCustomHtmlPattern()
|
||||
{
|
||||
$constraint = new Regex(array(
|
||||
'pattern' => '((?![0-9]$|[a-z]+).)*',
|
||||
'htmlPattern' => 'foobar',
|
||||
));
|
||||
|
||||
$this->assertSame('((?![0-9]$|[a-z]+).)*', $constraint->pattern);
|
||||
$this->assertSame('foobar', $constraint->getHtmlPattern());
|
||||
}
|
||||
}
|
93
vendor/symfony/validator/Tests/Constraints/RegexValidatorTest.php
vendored
Normal file
93
vendor/symfony/validator/Tests/Constraints/RegexValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?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\Constraints\Regex;
|
||||
use Symfony\Component\Validator\Constraints\RegexValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class RegexValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new RegexValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Regex(array('pattern' => '/^[0-9]+$/')));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Regex(array('pattern' => '/^[0-9]+$/')));
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Regex(array('pattern' => '/^[0-9]+$/')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidValues
|
||||
*/
|
||||
public function testValidValues($value)
|
||||
{
|
||||
$constraint = new Regex(array('pattern' => '/^[0-9]+$/'));
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidValues()
|
||||
{
|
||||
return array(
|
||||
array(0),
|
||||
array('0'),
|
||||
array('090909'),
|
||||
array(90909),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidValues
|
||||
*/
|
||||
public function testInvalidValues($value)
|
||||
{
|
||||
$constraint = new Regex(array(
|
||||
'pattern' => '/^[0-9]+$/',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$value.'"')
|
||||
->setCode(Regex::REGEX_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
{
|
||||
return array(
|
||||
array('abcd'),
|
||||
array('090foo'),
|
||||
);
|
||||
}
|
||||
}
|
109
vendor/symfony/validator/Tests/Constraints/TimeValidatorTest.php
vendored
Normal file
109
vendor/symfony/validator/Tests/Constraints/TimeValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?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\Constraints\Time;
|
||||
use Symfony\Component\Validator\Constraints\TimeValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class TimeValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new TimeValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Time());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Time());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testDateTimeClassIsValid()
|
||||
{
|
||||
$this->validator->validate(new \DateTime(), new Time());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Time());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidTimes
|
||||
*/
|
||||
public function testValidTimes($time)
|
||||
{
|
||||
$this->validator->validate($time, new Time());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidTimes()
|
||||
{
|
||||
return array(
|
||||
array('01:02:03'),
|
||||
array('00:00:00'),
|
||||
array('23:59:59'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTimes
|
||||
*/
|
||||
public function testInvalidTimes($time, $code)
|
||||
{
|
||||
$constraint = new Time(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($time, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$time.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidTimes()
|
||||
{
|
||||
return array(
|
||||
array('foobar', Time::INVALID_FORMAT_ERROR),
|
||||
array('foobar 12:34:56', Time::INVALID_FORMAT_ERROR),
|
||||
array('12:34:56 foobar', Time::INVALID_FORMAT_ERROR),
|
||||
array('00:00', Time::INVALID_FORMAT_ERROR),
|
||||
array('24:00:00', Time::INVALID_TIME_ERROR),
|
||||
array('00:60:00', Time::INVALID_TIME_ERROR),
|
||||
array('00:00:60', Time::INVALID_TIME_ERROR),
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateTimeImmutableIsValid()
|
||||
{
|
||||
$this->validator->validate(new \DateTimeImmutable(), new Time());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
}
|
182
vendor/symfony/validator/Tests/Constraints/TypeValidatorTest.php
vendored
Normal file
182
vendor/symfony/validator/Tests/Constraints/TypeValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,182 @@
|
|||
<?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\Constraints\Type;
|
||||
use Symfony\Component\Validator\Constraints\TypeValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class TypeValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected static $file;
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new TypeValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$constraint = new Type(array('type' => 'integer'));
|
||||
|
||||
$this->validator->validate(null, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyIsValidIfString()
|
||||
{
|
||||
$constraint = new Type(array('type' => 'string'));
|
||||
|
||||
$this->validator->validate('', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyIsInvalidIfNoString()
|
||||
{
|
||||
$constraint = new Type(array(
|
||||
'type' => 'integer',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('', $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '""')
|
||||
->setParameter('{{ type }}', 'integer')
|
||||
->setCode(Type::INVALID_TYPE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidValues
|
||||
*/
|
||||
public function testValidValues($value, $type)
|
||||
{
|
||||
$constraint = new Type(array('type' => $type));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidValues()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$file = $this->createFile();
|
||||
|
||||
return array(
|
||||
array(true, 'Boolean'),
|
||||
array(false, 'Boolean'),
|
||||
array(true, 'boolean'),
|
||||
array(false, 'boolean'),
|
||||
array(true, 'bool'),
|
||||
array(false, 'bool'),
|
||||
array(0, 'numeric'),
|
||||
array('0', 'numeric'),
|
||||
array(1.5, 'numeric'),
|
||||
array('1.5', 'numeric'),
|
||||
array(0, 'integer'),
|
||||
array(1.5, 'float'),
|
||||
array('12345', 'string'),
|
||||
array(array(), 'array'),
|
||||
array($object, 'object'),
|
||||
array($object, 'stdClass'),
|
||||
array($file, 'resource'),
|
||||
array('12345', 'digit'),
|
||||
array('12a34', 'alnum'),
|
||||
array('abcde', 'alpha'),
|
||||
array("\n\r\t", 'cntrl'),
|
||||
array('arf12', 'graph'),
|
||||
array('abcde', 'lower'),
|
||||
array('ABCDE', 'upper'),
|
||||
array('arf12', 'print'),
|
||||
array('*&$()', 'punct'),
|
||||
array("\n\r\t", 'space'),
|
||||
array('AB10BC99', 'xdigit'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidValues
|
||||
*/
|
||||
public function testInvalidValues($value, $type, $valueAsString)
|
||||
{
|
||||
$constraint = new Type(array(
|
||||
'type' => $type,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', $valueAsString)
|
||||
->setParameter('{{ type }}', $type)
|
||||
->setCode(Type::INVALID_TYPE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$file = $this->createFile();
|
||||
|
||||
return array(
|
||||
array('foobar', 'numeric', '"foobar"'),
|
||||
array('foobar', 'boolean', '"foobar"'),
|
||||
array('0', 'integer', '"0"'),
|
||||
array('1.5', 'float', '"1.5"'),
|
||||
array(12345, 'string', '12345'),
|
||||
array($object, 'boolean', 'object'),
|
||||
array($object, 'numeric', 'object'),
|
||||
array($object, 'integer', 'object'),
|
||||
array($object, 'float', 'object'),
|
||||
array($object, 'string', 'object'),
|
||||
array($object, 'resource', 'object'),
|
||||
array($file, 'boolean', 'resource'),
|
||||
array($file, 'numeric', 'resource'),
|
||||
array($file, 'integer', 'resource'),
|
||||
array($file, 'float', 'resource'),
|
||||
array($file, 'string', 'resource'),
|
||||
array($file, 'object', 'resource'),
|
||||
array('12a34', 'digit', '"12a34"'),
|
||||
array('1a#23', 'alnum', '"1a#23"'),
|
||||
array('abcd1', 'alpha', '"abcd1"'),
|
||||
array("\nabc", 'cntrl', "\"\nabc\""),
|
||||
array("abc\n", 'graph', "\"abc\n\""),
|
||||
array('abCDE', 'lower', '"abCDE"'),
|
||||
array('ABcde', 'upper', '"ABcde"'),
|
||||
array("\nabc", 'print', "\"\nabc\""),
|
||||
array('abc&$!', 'punct', '"abc&$!"'),
|
||||
array("\nabc", 'space', "\"\nabc\""),
|
||||
array('AR1012', 'xdigit', '"AR1012"'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function createFile()
|
||||
{
|
||||
if (!static::$file) {
|
||||
static::$file = fopen(__FILE__, 'r');
|
||||
}
|
||||
|
||||
return static::$file;
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
if (static::$file) {
|
||||
fclose(static::$file);
|
||||
static::$file = null;
|
||||
}
|
||||
}
|
||||
}
|
306
vendor/symfony/validator/Tests/Constraints/UrlValidatorTest.php
vendored
Normal file
306
vendor/symfony/validator/Tests/Constraints/UrlValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,306 @@
|
|||
<?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\Bridge\PhpUnit\DnsMock;
|
||||
use Symfony\Component\Validator\Constraints\Url;
|
||||
use Symfony\Component\Validator\Constraints\UrlValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @group dns-sensitive
|
||||
*/
|
||||
class UrlValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new UrlValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Url());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Url());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringFromObjectIsValid()
|
||||
{
|
||||
$this->validator->validate(new EmailProvider(), new Url());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Url());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidUrls
|
||||
*/
|
||||
public function testValidUrls($url)
|
||||
{
|
||||
$this->validator->validate($url, new Url());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidUrls()
|
||||
{
|
||||
return array(
|
||||
array('http://a.pl'),
|
||||
array('http://www.google.com'),
|
||||
array('http://www.google.com.'),
|
||||
array('http://www.google.museum'),
|
||||
array('https://google.com/'),
|
||||
array('https://google.com:80/'),
|
||||
array('http://www.example.coop/'),
|
||||
array('http://www.test-example.com/'),
|
||||
array('http://www.symfony.com/'),
|
||||
array('http://symfony.fake/blog/'),
|
||||
array('http://symfony.com/?'),
|
||||
array('http://symfony.com/search?type=&q=url+validator'),
|
||||
array('http://symfony.com/#'),
|
||||
array('http://symfony.com/#?'),
|
||||
array('http://www.symfony.com/doc/current/book/validation.html#supported-constraints'),
|
||||
array('http://very.long.domain.name.com/'),
|
||||
array('http://localhost/'),
|
||||
array('http://myhost123/'),
|
||||
array('http://127.0.0.1/'),
|
||||
array('http://127.0.0.1:80/'),
|
||||
array('http://[::1]/'),
|
||||
array('http://[::1]:80/'),
|
||||
array('http://[1:2:3::4:5:6:7]/'),
|
||||
array('http://sãopaulo.com/'),
|
||||
array('http://xn--sopaulo-xwa.com/'),
|
||||
array('http://sãopaulo.com.br/'),
|
||||
array('http://xn--sopaulo-xwa.com.br/'),
|
||||
array('http://пример.испытание/'),
|
||||
array('http://xn--e1afmkfd.xn--80akhbyknj4f/'),
|
||||
array('http://مثال.إختبار/'),
|
||||
array('http://xn--mgbh0fb.xn--kgbechtv/'),
|
||||
array('http://例子.测试/'),
|
||||
array('http://xn--fsqu00a.xn--0zwm56d/'),
|
||||
array('http://例子.測試/'),
|
||||
array('http://xn--fsqu00a.xn--g6w251d/'),
|
||||
array('http://例え.テスト/'),
|
||||
array('http://xn--r8jz45g.xn--zckzah/'),
|
||||
array('http://مثال.آزمایشی/'),
|
||||
array('http://xn--mgbh0fb.xn--hgbk6aj7f53bba/'),
|
||||
array('http://실례.테스트/'),
|
||||
array('http://xn--9n2bp8q.xn--9t4b11yi5a/'),
|
||||
array('http://العربية.idn.icann.org/'),
|
||||
array('http://xn--ogb.idn.icann.org/'),
|
||||
array('http://xn--e1afmkfd.xn--80akhbyknj4f.xn--e1afmkfd/'),
|
||||
array('http://xn--espaa-rta.xn--ca-ol-fsay5a/'),
|
||||
array('http://xn--d1abbgf6aiiy.xn--p1ai/'),
|
||||
array('http://☎.com/'),
|
||||
array('http://username:password@symfony.com'),
|
||||
array('http://user.name:password@symfony.com'),
|
||||
array('http://username:pass.word@symfony.com'),
|
||||
array('http://user.name:pass.word@symfony.com'),
|
||||
array('http://user-name@symfony.com'),
|
||||
array('http://symfony.com?'),
|
||||
array('http://symfony.com?query=1'),
|
||||
array('http://symfony.com/?query=1'),
|
||||
array('http://symfony.com#'),
|
||||
array('http://symfony.com#fragment'),
|
||||
array('http://symfony.com/#fragment'),
|
||||
array('http://symfony.com/#one_more%20test'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidUrls
|
||||
*/
|
||||
public function testInvalidUrls($url)
|
||||
{
|
||||
$constraint = new Url(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($url, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$url.'"')
|
||||
->setCode(Url::INVALID_URL_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidUrls()
|
||||
{
|
||||
return array(
|
||||
array('google.com'),
|
||||
array('://google.com'),
|
||||
array('http ://google.com'),
|
||||
array('http:/google.com'),
|
||||
array('http://goog_le.com'),
|
||||
array('http://google.com::aa'),
|
||||
array('http://google.com:aa'),
|
||||
array('ftp://google.fr'),
|
||||
array('faked://google.fr'),
|
||||
array('http://127.0.0.1:aa/'),
|
||||
array('ftp://[::1]/'),
|
||||
array('http://[::1'),
|
||||
array('http://hello.☎/'),
|
||||
array('http://:password@symfony.com'),
|
||||
array('http://:password@@symfony.com'),
|
||||
array('http://username:passwordsymfony.com'),
|
||||
array('http://usern@me:password@symfony.com'),
|
||||
array('http://example.com/exploit.html?<script>alert(1);</script>'),
|
||||
array('http://example.com/exploit.html?hel lo'),
|
||||
array('http://example.com/exploit.html?not_a%hex'),
|
||||
array('http://'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidCustomUrls
|
||||
*/
|
||||
public function testCustomProtocolIsValid($url)
|
||||
{
|
||||
$constraint = new Url(array(
|
||||
'protocols' => array('ftp', 'file', 'git'),
|
||||
));
|
||||
|
||||
$this->validator->validate($url, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidCustomUrls()
|
||||
{
|
||||
return array(
|
||||
array('ftp://google.com'),
|
||||
array('file://127.0.0.1'),
|
||||
array('git://[::1]/'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCheckDns
|
||||
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
|
||||
*/
|
||||
public function testCheckDns($violation)
|
||||
{
|
||||
DnsMock::withMockedHosts(array('example.com' => array(array('type' => $violation ? '' : 'A'))));
|
||||
|
||||
$constraint = new Url(array(
|
||||
'checkDNS' => 'ANY',
|
||||
'dnsMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('http://example.com', $constraint);
|
||||
|
||||
if (!$violation) {
|
||||
$this->assertNoViolation();
|
||||
} else {
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"example.com"')
|
||||
->setCode(Url::INVALID_URL_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
||||
|
||||
public function getCheckDns()
|
||||
{
|
||||
return array(array(true), array(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCheckDnsTypes
|
||||
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
|
||||
*/
|
||||
public function testCheckDnsByType($type)
|
||||
{
|
||||
DnsMock::withMockedHosts(array('example.com' => array(array('type' => $type))));
|
||||
|
||||
$constraint = new Url(array(
|
||||
'checkDNS' => $type,
|
||||
'dnsMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('http://example.com', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getCheckDnsTypes()
|
||||
{
|
||||
return array(
|
||||
array('ANY'),
|
||||
array('A'),
|
||||
array('A6'),
|
||||
array('AAAA'),
|
||||
array('CNAME'),
|
||||
array('MX'),
|
||||
array('NAPTR'),
|
||||
array('NS'),
|
||||
array('PTR'),
|
||||
array('SOA'),
|
||||
array('SRV'),
|
||||
array('TXT'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testCheckDnsWithBoolean()
|
||||
{
|
||||
DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A'))));
|
||||
|
||||
$constraint = new Url(array(
|
||||
'checkDNS' => true,
|
||||
'dnsMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('http://example.com', $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException
|
||||
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
|
||||
*/
|
||||
public function testCheckDnsWithInvalidType()
|
||||
{
|
||||
DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A'))));
|
||||
|
||||
$constraint = new Url(array(
|
||||
'checkDNS' => 'BOGUS',
|
||||
'dnsMessage' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate('http://example.com', $constraint);
|
||||
}
|
||||
}
|
||||
|
||||
class EmailProvider
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
216
vendor/symfony/validator/Tests/Constraints/UuidValidatorTest.php
vendored
Normal file
216
vendor/symfony/validator/Tests/Constraints/UuidValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,216 @@
|
|||
<?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\Constraints\Uuid;
|
||||
use Symfony\Component\Validator\Constraints\UuidValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @author Colin O'Dell <colinodell@gmail.com>
|
||||
*/
|
||||
class UuidValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new UuidValidator();
|
||||
}
|
||||
|
||||
public function testNullIsValid()
|
||||
{
|
||||
$this->validator->validate(null, new Uuid());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testEmptyStringIsValid()
|
||||
{
|
||||
$this->validator->validate('', new Uuid());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsUuidConstraintCompatibleType()
|
||||
{
|
||||
$constraint = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\Constraint');
|
||||
|
||||
$this->validator->validate('216fff40-98d9-11e3-a5e2-0800200c9a66', $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->validator->validate(new \stdClass(), new Uuid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidStrictUuids
|
||||
*/
|
||||
public function testValidStrictUuids($uuid, $versions = null)
|
||||
{
|
||||
$constraint = new Uuid();
|
||||
|
||||
if (null !== $versions) {
|
||||
$constraint->versions = $versions;
|
||||
}
|
||||
|
||||
$this->validator->validate($uuid, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidStrictUuids()
|
||||
{
|
||||
return array(
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a66'), // Version 1 UUID in lowercase
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a66', array(Uuid::V1_MAC)),
|
||||
array('216FFF40-98D9-11E3-A5E2-0800200C9A66'), // Version 1 UUID in UPPERCASE
|
||||
array('456daefb-5aa6-41b5-8dbc-068b05a8b201'), // Version 4 UUID in lowercase
|
||||
array('456daEFb-5AA6-41B5-8DBC-068B05A8B201'), // Version 4 UUID in mixed case
|
||||
array('456daEFb-5AA6-41B5-8DBC-068B05A8B201', array(Uuid::V4_RANDOM)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidStrictUuids
|
||||
*/
|
||||
public function testInvalidStrictUuids($uuid, $code, $versions = null)
|
||||
{
|
||||
$constraint = new Uuid(array(
|
||||
'message' => 'testMessage',
|
||||
));
|
||||
|
||||
if (null !== $versions) {
|
||||
$constraint->versions = $versions;
|
||||
}
|
||||
|
||||
$this->validator->validate($uuid, $constraint);
|
||||
|
||||
$this->buildViolation('testMessage')
|
||||
->setParameter('{{ value }}', '"'.$uuid.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidStrictUuids()
|
||||
{
|
||||
return array(
|
||||
array('216fff40-98d9-11e3-a5e2_0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('216gff40-98d9-11e3-a5e2-0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('216Gff40-98d9-11e3-a5e2-0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e-20800200c9a66', Uuid::INVALID_HYPHEN_PLACEMENT_ERROR),
|
||||
array('216f-ff40-98d9-11e3-a5e2-0800200c9a66', Uuid::INVALID_HYPHEN_PLACEMENT_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2-0800-200c9a66', Uuid::INVALID_HYPHEN_PLACEMENT_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c-9a66', Uuid::INVALID_HYPHEN_PLACEMENT_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e20800200c9a66', Uuid::INVALID_HYPHEN_PLACEMENT_ERROR),
|
||||
array('216fff4098d911e3a5e20800200c9a66', Uuid::INVALID_HYPHEN_PLACEMENT_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a6', Uuid::TOO_SHORT_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a666', Uuid::TOO_LONG_ERROR),
|
||||
array('216fff40-98d9-01e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-61e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-71e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-81e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-91e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-a1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-b1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-c1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-d1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-e1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-f1e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR, array(Uuid::V2_DCE, Uuid::V3_MD5, Uuid::V4_RANDOM, Uuid::V5_SHA1)),
|
||||
array('216fff40-98d9-21e3-a5e2-0800200c9a66', Uuid::INVALID_VERSION_ERROR, array(Uuid::V1_MAC, Uuid::V3_MD5, Uuid::V4_RANDOM, Uuid::V5_SHA1)),
|
||||
array('216fff40-98d9-11e3-05e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-15e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-25e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-35e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-45e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-55e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-65e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-75e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-c5e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-d5e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-e5e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
array('216fff40-98d9-11e3-f5e2-0800200c9a66', Uuid::INVALID_VARIANT_ERROR),
|
||||
|
||||
// Non-standard UUID allowed by some other systems
|
||||
array('{216fff40-98d9-11e3-a5e2-0800200c9a66}', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('[216fff40-98d9-11e3-a5e2-0800200c9a66]', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidNonStrictUuids
|
||||
*/
|
||||
public function testValidNonStrictUuids($uuid)
|
||||
{
|
||||
$constraint = new Uuid(array(
|
||||
'strict' => false,
|
||||
));
|
||||
|
||||
$this->validator->validate($uuid, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getValidNonStrictUuids()
|
||||
{
|
||||
return array(
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a66'), // Version 1 UUID in lowercase
|
||||
array('216FFF40-98D9-11E3-A5E2-0800200C9A66'), // Version 1 UUID in UPPERCASE
|
||||
array('456daefb-5aa6-41b5-8dbc-068b05a8b201'), // Version 4 UUID in lowercase
|
||||
array('456DAEFb-5AA6-41B5-8DBC-068b05a8B201'), // Version 4 UUID in mixed case
|
||||
|
||||
// Non-standard UUIDs allowed by some other systems
|
||||
array('216f-ff40-98d9-11e3-a5e2-0800-200c-9a66'), // Non-standard dash positions (every 4 chars)
|
||||
array('216fff40-98d911e3-a5e20800-200c9a66'), // Non-standard dash positions (every 8 chars)
|
||||
array('216fff4098d911e3a5e20800200c9a66'), // No dashes at all
|
||||
array('{216fff40-98d9-11e3-a5e2-0800200c9a66}'), // Wrapped with curly braces
|
||||
array('[216fff40-98d9-11e3-a5e2-0800200c9a66]'), // Wrapped with squared braces
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidNonStrictUuids
|
||||
*/
|
||||
public function testInvalidNonStrictUuids($uuid, $code)
|
||||
{
|
||||
$constraint = new Uuid(array(
|
||||
'strict' => false,
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($uuid, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"'.$uuid.'"')
|
||||
->setCode($code)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getInvalidNonStrictUuids()
|
||||
{
|
||||
return array(
|
||||
array('216fff40-98d9-11e3-a5e2_0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('216gff40-98d9-11e3-a5e2-0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('216Gff40-98d9-11e3-a5e2-0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2_0800200c9a6', Uuid::INVALID_CHARACTERS_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e-20800200c9a66', Uuid::INVALID_HYPHEN_PLACEMENT_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a6', Uuid::TOO_SHORT_ERROR),
|
||||
array('216fff40-98d9-11e3-a5e2-0800200c9a666', Uuid::TOO_LONG_ERROR),
|
||||
);
|
||||
}
|
||||
}
|
35
vendor/symfony/validator/Tests/Constraints/ValidTest.php
vendored
Normal file
35
vendor/symfony/validator/Tests/Constraints/ValidTest.php
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?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 PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\Valid;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class ValidTest extends TestCase
|
||||
{
|
||||
public function testGroupsCanBeSet()
|
||||
{
|
||||
$constraint = new Valid(array('groups' => 'foo'));
|
||||
|
||||
$this->assertSame(array('foo'), $constraint->groups);
|
||||
}
|
||||
|
||||
public function testGroupsAreNullByDefault()
|
||||
{
|
||||
$constraint = new Valid();
|
||||
|
||||
$this->assertNull($constraint->groups);
|
||||
}
|
||||
}
|
73
vendor/symfony/validator/Tests/Constraints/ValidValidatorTest.php
vendored
Normal file
73
vendor/symfony/validator/Tests/Constraints/ValidValidatorTest.php
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Constraints\ValidValidator;
|
||||
use Symfony\Component\Validator\ValidatorBuilder;
|
||||
|
||||
class ValidValidatorTest extends TestCase
|
||||
{
|
||||
public function testPropertyPathsArePassedToNestedContexts()
|
||||
{
|
||||
$validatorBuilder = new ValidatorBuilder();
|
||||
$validator = $validatorBuilder->enableAnnotationMapping()->getValidator();
|
||||
|
||||
$violations = $validator->validate(new Foo(), null, array('nested'));
|
||||
|
||||
$this->assertCount(1, $violations);
|
||||
$this->assertSame('fooBar.fooBarBaz.foo', $violations->get(0)->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testNullValues()
|
||||
{
|
||||
$validatorBuilder = new ValidatorBuilder();
|
||||
$validator = $validatorBuilder->enableAnnotationMapping()->getValidator();
|
||||
|
||||
$foo = new Foo();
|
||||
$foo->fooBar = null;
|
||||
$violations = $validator->validate($foo, null, array('nested'));
|
||||
|
||||
$this->assertCount(0, $violations);
|
||||
}
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new ValidValidator();
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
/**
|
||||
* @Assert\Valid(groups={"nested"})
|
||||
*/
|
||||
public $fooBar;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fooBar = new FooBar();
|
||||
}
|
||||
}
|
||||
|
||||
class FooBar
|
||||
{
|
||||
/**
|
||||
* @Assert\Valid(groups={"nested"})
|
||||
*/
|
||||
public $fooBarBaz;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fooBarBaz = new FooBarBaz();
|
||||
}
|
||||
}
|
||||
|
||||
class FooBarBaz
|
||||
{
|
||||
/**
|
||||
* @Assert\NotBlank(groups={"nested"})
|
||||
*/
|
||||
public $foo;
|
||||
}
|
Reference in a new issue