use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class ComparisonTest_Class
{
/**
* @author Daniel Holmes <daniel@danielholmes.org>
*/
-abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintValidatorTest
+abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
{
protected static function addPhp5Dot5Comparisons(array $comparisons)
{
- if (\PHP_VERSION_ID < 50500) {
- return $comparisons;
- }
-
$result = $comparisons;
// Duplicate all tests involving DateTime objects to be tested with
return $result;
}
+ public function provideInvalidConstraintOptions()
+ {
+ return array(
+ array(null),
+ array(array()),
+ );
+ }
+
/**
+ * @dataProvider provideInvalidConstraintOptions
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
*/
- public function testThrowsConstraintExceptionIfNoValueOrProperty()
+ public function testThrowsConstraintExceptionIfNoValueOrProperty($options)
{
- $comparison = $this->createConstraint(array());
-
- $this->validator->validate('some value', $comparison);
+ $this->createConstraint($options);
}
/**
// Make sure we have the correct version loaded
if ($dirtyValue instanceof \DateTime || $dirtyValue instanceof \DateTimeInterface) {
IntlTestHelper::requireIntl($this, '57.1');
-
- if (\PHP_VERSION_ID < 50304 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
- $this->markTestSkipped('Intl supports formatting DateTime objects since 5.3.4');
- }
}
$constraint = $this->createConstraint(array('value' => $comparedValue));
abstract public function provideInvalidComparisons();
/**
- * @param array $options Options for the constraint
+ * @param array|null $options Options for the constraint
*
* @return Constraint
*/
- abstract protected function createConstraint(array $options);
+ abstract protected function createConstraint(array $options = null);
/**
* @return string|null