Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[Validator] Rename "Choice" to "OneOf" #6360

Merged
merged 1 commit into from

6 participants

@ricardclau

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #6324
Todo:
License of the code: MIT
Documentation PR: symfony/symfony-docs#2025

@webmozart
Collaborator

Can you let Choice and ChoiceValidator extend the renamed classes? Then we avoid the code duplication. You can also remove ChoiceValidatorTest then.

@ricardclau

For sure! BTW there seems to be a problem with SF2 build when testing BR currency :S maybe it is the new ICU version supported, I guess you are aware of this but just in case!

@ricardclau ricardclau referenced this pull request in symfony/symfony-docs
Closed

[Validator] Rename "Choice" to "OneOf" #2025

@stof
Collaborator

the Choice constraint should trigger a E_USER_DEPRECATED in its constructor (and calling the parent constructor) as we agreed on this. The PR adding these calls everywhere is not merged yet, but it would avoid missing it when merging the PRs separately

@webmozart webmozart commented on the diff
src/Symfony/Component/Validator/Constraints/Choice.php
((6 lines not shown))
/**
* @Annotation
*
* @api
+ *
+ * @deprecated Deprecated since version 2.2, to be removed in 2.3.
@webmozart Collaborator

Please add Use {@link OneOf} instead. here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@webmozart webmozart commented on the diff
...y/Component/Validator/Constraints/ChoiceValidator.php
@@ -24,60 +19,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
+ *
+ * @deprecated Deprecated since version 2.2, to be removed in 2.3.
@webmozart Collaborator

Please add Use {@link OneOfValidator} instead. here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@webmozart
Collaborator

Things missing:

  • add a deprecation note to the Validator's CHANGELOG
  • add a block in UPGRADE-2.2 under the Validator's "Deprecations" section that explains how to upgrade with a before/after sample
  • add trigger_error() calls to the constructors of Choice and ChoiceValidator

See #6180 for more information about how to call trigger_error().

@ricardclau

Sorry I was not aware of the trigger_error() agreement, absolutely +1 on it.

I hope I understood everything properly, if there is something else or some other errors please tell me!

@webmozart
Collaborator

The entry in the CHANGELOG is still missing.

@ricardclau ricardclau create oneof constraint and add deprecation messages in choice, also …
…make choice extend new oneOf constraint to avoid duplicate code
9071676
@ricardclau

By the CHANGELOG you mean what I just added right? Hope now it is ok!

@webmozart
Collaborator

Awesome! :+1:

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch ricardclau/rename_choice_to_oneof (PR #6360)
This PR was merged into the master branch.

Commits
-------

9071676 create oneof constraint and add deprecation messages in choice, also make choice extend new oneOf constraint to avoid duplicate code

Discussion
----------

[Validator] Rename "Choice" to "OneOf"

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #6324
Todo:
License of the code: MIT
Documentation PR: symfony/symfony-docs#2025

---------------------------------------------------------------------------

by bschussek at 2012-12-14T18:20:56Z

Can you let `Choice` and `ChoiceValidator` extend the renamed classes? Then we avoid the code duplication. You can also remove `ChoiceValidatorTest` then.

---------------------------------------------------------------------------

by ricardclau at 2012-12-14T18:26:58Z

For sure! BTW there seems to be a problem with SF2 build when testing BR currency :S maybe it is the new ICU version supported, I guess you are aware of this but just in case!

---------------------------------------------------------------------------

by stof at 2012-12-14T21:14:04Z

the ``Choice`` constraint should trigger a ``E_USER_DEPRECATED`` in its constructor (and calling the parent constructor) as we agreed on this. The PR adding these calls everywhere is not merged yet, but it would avoid missing it when merging the PRs separately

---------------------------------------------------------------------------

by bschussek at 2012-12-14T21:19:45Z

Things missing:

* add a deprecation note to the Validator's CHANGELOG
* add a block in UPGRADE-2.2 under the Validator's "Deprecations" section that explains how to upgrade with a before/after sample
* add `trigger_error()` calls to the constructors of `Choice` and `ChoiceValidator`

See #6180 for more information about how to call `trigger_error()`.

---------------------------------------------------------------------------

by ricardclau at 2012-12-14T22:45:55Z

Sorry I was not aware of the trigger_error() agreement, absolutely +1 on it.

I hope I understood everything properly, if there is something else or some other errors please tell me!

---------------------------------------------------------------------------

by bschussek at 2012-12-15T08:46:51Z

The entry in the CHANGELOG is still missing.

---------------------------------------------------------------------------

by ricardclau at 2012-12-15T09:36:28Z

By the CHANGELOG you mean what I just added right? Hope now it is ok!

---------------------------------------------------------------------------

by bschussek at 2012-12-15T09:45:16Z

Awesome! :+1:
1de60c9
@fabpot fabpot merged commit 9071676 into from
@vicb

In what OneOf is better than Choice ?

@Tobion
Collaborator

I also wonder why it's supposed to be better? And even break bc later for this.

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot Revert "merged branch ricardclau/rename_choice_to_oneof (PR #6360)"
This reverts commit 1de60c9, reversing
changes made to e3cc337.

Conflicts:
	UPGRADE-2.2.md
79148f3
@fabpot
Owner

This has been reverted.

@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch ricardclau/rename_choice_to_oneof (PR #6360)
This PR was merged into the master branch.

Commits
-------

9071676 create oneof constraint and add deprecation messages in choice, also make choice extend new oneOf constraint to avoid duplicate code

Discussion
----------

[Validator] Rename "Choice" to "OneOf"

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #6324
Todo:
License of the code: MIT
Documentation PR: symfony/symfony-docs#2025

---------------------------------------------------------------------------

by bschussek at 2012-12-14T18:20:56Z

Can you let `Choice` and `ChoiceValidator` extend the renamed classes? Then we avoid the code duplication. You can also remove `ChoiceValidatorTest` then.

---------------------------------------------------------------------------

by ricardclau at 2012-12-14T18:26:58Z

For sure! BTW there seems to be a problem with SF2 build when testing BR currency :S maybe it is the new ICU version supported, I guess you are aware of this but just in case!

---------------------------------------------------------------------------

by stof at 2012-12-14T21:14:04Z

the ``Choice`` constraint should trigger a ``E_USER_DEPRECATED`` in its constructor (and calling the parent constructor) as we agreed on this. The PR adding these calls everywhere is not merged yet, but it would avoid missing it when merging the PRs separately

---------------------------------------------------------------------------

by bschussek at 2012-12-14T21:19:45Z

Things missing:

* add a deprecation note to the Validator's CHANGELOG
* add a block in UPGRADE-2.2 under the Validator's "Deprecations" section that explains how to upgrade with a before/after sample
* add `trigger_error()` calls to the constructors of `Choice` and `ChoiceValidator`

See #6180 for more information about how to call `trigger_error()`.

---------------------------------------------------------------------------

by ricardclau at 2012-12-14T22:45:55Z

Sorry I was not aware of the trigger_error() agreement, absolutely +1 on it.

I hope I understood everything properly, if there is something else or some other errors please tell me!

---------------------------------------------------------------------------

by bschussek at 2012-12-15T08:46:51Z

The entry in the CHANGELOG is still missing.

---------------------------------------------------------------------------

by ricardclau at 2012-12-15T09:36:28Z

By the CHANGELOG you mean what I just added right? Hope now it is ok!

---------------------------------------------------------------------------

by bschussek at 2012-12-15T09:45:16Z

Awesome! :+1:
54d5c61
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot Revert "merged branch ricardclau/rename_choice_to_oneof (PR #6360)"
This reverts commit 1de60c9, reversing
changes made to e3cc337.

Conflicts:
	UPGRADE-2.2.md
090ee48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 15, 2012
  1. @ricardclau

    create oneof constraint and add deprecation messages in choice, also …

    ricardclau authored
    …make choice extend new oneOf constraint to avoid duplicate code
This page is out of date. Refresh to see the latest.
View
18 UPGRADE-2.2.md
@@ -319,3 +319,21 @@
// ...
}
```
+
+ * The constraint `Choice` was deprecated and will be removed in Symfony 2.3.
+ You should use the new constraint `OneOf` instead.
+
+ Before:
+
+ ```
+ /** @Assert\Choice(choices = {"male", "female"}, message = "Choose a valid gender.") */
+ protected $gender;
+ ```
+
+ After:
+
+ ```
+ /** @Assert\OneOf(choices = {"male", "female"}, message = "Choose a valid gender.") */
+ protected $gender;
+ ```
+
View
1  src/Symfony/Component/Validator/CHANGELOG.md
@@ -28,6 +28,7 @@ CHANGELOG
As of Symfony 2.3, this method will be typed against `MetadataFactoryInterface` instead.
* [BC BREAK] the switches `traverse` and `deep` in the `Valid` constraint and in `GraphWalker::walkReference`
are ignored for arrays now. Arrays are always traversed recursively.
+ * deprecated `Choice` constraint in favor of the new `OneOf` constraint.
2.1.0
-----
View
26 src/Symfony/Component/Validator/Constraints/Choice.php
@@ -11,31 +11,19 @@
namespace Symfony\Component\Validator\Constraints;
-use Symfony\Component\Validator\Constraint;
-
/**
* @Annotation
*
* @api
+ *
+ * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use
@webmozart Collaborator

Please add Use {@link OneOf} instead. here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ * {@link OneOf} instead.
*/
-class Choice extends Constraint
+class Choice extends OneOf
{
- public $choices;
- public $callback;
- public $multiple = false;
- public $strict = false;
- public $min = null;
- public $max = null;
- public $message = 'The value you selected is not a valid choice.';
- public $multipleMessage = 'One or more of the given values is invalid.';
- public $minMessage = 'You must select at least {{ limit }} choices.';
- public $maxMessage = 'You must select at most {{ limit }} choices.';
-
- /**
- * {@inheritDoc}
- */
- public function getDefaultOption()
+ public function __construct($options = null)
{
- return 'choices';
+ trigger_error('Choice constraint is deprecated since version 2.2 and will be removed in 2.3. Use OneOf instead', E_USER_DEPRECATED);
+ parent::__construct($options);
}
}
View
64 src/Symfony/Component/Validator/Constraints/ChoiceValidator.php
@@ -11,11 +11,6 @@
namespace Symfony\Component\Validator\Constraints;
-use Symfony\Component\Validator\Constraint;
-use Symfony\Component\Validator\ConstraintValidator;
-use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
-use Symfony\Component\Validator\Exception\UnexpectedTypeException;
-
/**
* ChoiceValidator validates that the value is one of the expected values.
*
@@ -24,60 +19,15 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
+ *
+ * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use
@webmozart Collaborator

Please add Use {@link OneOfValidator} instead. here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ * {@link OneOfValidator} instead.
*/
-class ChoiceValidator extends ConstraintValidator
+class ChoiceValidator extends OneOfValidator
{
- /**
- * {@inheritDoc}
- */
- public function validate($value, Constraint $constraint)
+ public function __construct($options = null)
{
- if (!$constraint->choices && !$constraint->callback) {
- throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice');
- }
-
- if (null === $value) {
- return;
- }
-
- if ($constraint->multiple && !is_array($value)) {
- throw new UnexpectedTypeException($value, 'array');
- }
-
- if ($constraint->callback) {
- if (is_callable(array($this->context->getCurrentClass(), $constraint->callback))) {
- $choices = call_user_func(array($this->context->getCurrentClass(), $constraint->callback));
- } elseif (is_callable($constraint->callback)) {
- $choices = call_user_func($constraint->callback);
- } else {
- throw new ConstraintDefinitionException('The Choice constraint expects a valid callback');
- }
- } else {
- $choices = $constraint->choices;
- }
-
- if ($constraint->multiple) {
- foreach ($value as $_value) {
- if (!in_array($_value, $choices, $constraint->strict)) {
- $this->context->addViolation($constraint->multipleMessage, array('{{ value }}' => $_value));
- }
- }
-
- $count = count($value);
-
- if ($constraint->min !== null && $count < $constraint->min) {
- $this->context->addViolation($constraint->minMessage, array('{{ limit }}' => $constraint->min), null, (int) $constraint->min);
-
- return;
- }
-
- if ($constraint->max !== null && $count > $constraint->max) {
- $this->context->addViolation($constraint->maxMessage, array('{{ limit }}' => $constraint->max), null, (int) $constraint->max);
-
- return;
- }
- } elseif (!in_array($value, $choices, $constraint->strict)) {
- $this->context->addViolation($constraint->message, array('{{ value }}' => $value));
- }
+ trigger_error('ChoiceValidator is deprecated since version 2.2 and will be removed in 2.3. Use OneOfValidator instead', E_USER_DEPRECATED);
+ parent::__construct($options);
}
}
View
41 src/Symfony/Component/Validator/Constraints/OneOf.php
@@ -0,0 +1,41 @@
+<?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\Constraints;
+
+use Symfony\Component\Validator\Constraint;
+
+/**
+ * @Annotation
+ *
+ * @api
+ */
+class OneOf extends Constraint
+{
+ public $choices;
+ public $callback;
+ public $multiple = false;
+ public $strict = false;
+ public $min = null;
+ public $max = null;
+ public $message = 'The value you selected is not a valid choice.';
+ public $multipleMessage = 'One or more of the given values is invalid.';
+ public $minMessage = 'You must select at least {{ limit }} choices.';
+ public $maxMessage = 'You must select at most {{ limit }} choices.';
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getDefaultOption()
+ {
+ return 'choices';
+ }
+}
View
83 src/Symfony/Component/Validator/Constraints/OneOfValidator.php
@@ -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\Constraints;
+
+use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\ConstraintValidator;
+use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
+use Symfony\Component\Validator\Exception\UnexpectedTypeException;
+
+/**
+ * ChoiceValidator validates that the value is one of the expected values.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ * @author Florian Eckerstorfer <florian@eckerstorfer.org>
+ * @author Bernhard Schussek <bschussek@gmail.com>
+ *
+ * @api
+ */
+class OneOfValidator extends ConstraintValidator
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function validate($value, Constraint $constraint)
+ {
+ if (!$constraint->choices && !$constraint->callback) {
+ throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice');
+ }
+
+ if (null === $value) {
+ return;
+ }
+
+ if ($constraint->multiple && !is_array($value)) {
+ throw new UnexpectedTypeException($value, 'array');
+ }
+
+ if ($constraint->callback) {
+ if (is_callable(array($this->context->getCurrentClass(), $constraint->callback))) {
+ $choices = call_user_func(array($this->context->getCurrentClass(), $constraint->callback));
+ } elseif (is_callable($constraint->callback)) {
+ $choices = call_user_func($constraint->callback);
+ } else {
+ throw new ConstraintDefinitionException('The OneOf constraint expects a valid callback');
+ }
+ } else {
+ $choices = $constraint->choices;
+ }
+
+ if ($constraint->multiple) {
+ foreach ($value as $_value) {
+ if (!in_array($_value, $choices, $constraint->strict)) {
+ $this->context->addViolation($constraint->multipleMessage, array('{{ value }}' => $_value));
+ }
+ }
+
+ $count = count($value);
+
+ if ($constraint->min !== null && $count < $constraint->min) {
+ $this->context->addViolation($constraint->minMessage, array('{{ limit }}' => $constraint->min), null, (int) $constraint->min);
+
+ return;
+ }
+
+ if ($constraint->max !== null && $count > $constraint->max) {
+ $this->context->addViolation($constraint->maxMessage, array('{{ limit }}' => $constraint->max), null, (int) $constraint->max);
+
+ return;
+ }
+ } elseif (!in_array($value, $choices, $constraint->strict)) {
+ $this->context->addViolation($constraint->message, array('{{ value }}' => $value));
+ }
+ }
+}
View
72 ...lidator/Tests/Constraints/ChoiceValidatorTest.php → ...alidator/Tests/Constraints/OneOfValidatorTest.php
@@ -12,15 +12,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\ExecutionContext;
-use Symfony\Component\Validator\Constraints\Choice;
-use Symfony\Component\Validator\Constraints\ChoiceValidator;
+use Symfony\Component\Validator\Constraints\OneOf;
+use Symfony\Component\Validator\Constraints\OneOfValidator;
-function choice_callback()
+function oneof_callback()
{
return array('foo', 'bar');
}
-class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
+class OneOfValidatorTest extends \PHPUnit_Framework_TestCase
{
protected $context;
protected $validator;
@@ -33,7 +33,7 @@ public static function staticCallback()
protected function setUp()
{
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
- $this->validator = new ChoiceValidator();
+ $this->validator = new OneOfValidator();
$this->validator->initialize($this->context);
$this->context->expects($this->any())
@@ -52,7 +52,7 @@ protected function tearDown()
*/
public function testExpectArrayIfMultipleIsTrue()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array('foo', 'bar'),
'multiple' => true,
));
@@ -65,7 +65,7 @@ public function testNullIsValid()
$this->context->expects($this->never())
->method('addViolation');
- $this->validator->validate(null, new Choice(array('choices' => array('foo', 'bar'))));
+ $this->validator->validate(null, new OneOf(array('choices' => array('foo', 'bar'))));
}
/**
@@ -73,7 +73,7 @@ public function testNullIsValid()
*/
public function testChoicesOrCallbackExpected()
{
- $this->validator->validate('foobar', new Choice());
+ $this->validator->validate('foobar', new OneOf());
}
/**
@@ -81,12 +81,12 @@ public function testChoicesOrCallbackExpected()
*/
public function testValidCallbackExpected()
{
- $this->validator->validate('foobar', new Choice(array('callback' => 'abcd')));
+ $this->validator->validate('foobar', new OneOf(array('callback' => 'abcd')));
}
- public function testValidChoiceArray()
+ public function testValidOneOfChoicesArray()
{
- $constraint = new Choice(array('choices' => array('foo', 'bar')));
+ $constraint = new OneOf(array('choices' => array('foo', 'bar')));
$this->context->expects($this->never())
->method('addViolation');
@@ -94,9 +94,9 @@ public function testValidChoiceArray()
$this->validator->validate('bar', $constraint);
}
- public function testValidChoiceCallbackFunction()
+ public function testValidOneOfCallbackFunction()
{
- $constraint = new Choice(array('callback' => __NAMESPACE__.'\choice_callback'));
+ $constraint = new OneOf(array('callback' => __NAMESPACE__.'\oneof_callback'));
$this->context->expects($this->never())
->method('addViolation');
@@ -104,9 +104,9 @@ public function testValidChoiceCallbackFunction()
$this->validator->validate('bar', $constraint);
}
- public function testValidChoiceCallbackClosure()
+ public function testValidOneOfCallbackClosure()
{
- $constraint = new Choice(array('callback' => function() {
+ $constraint = new OneOf(array('callback' => function() {
return array('foo', 'bar');
}));
@@ -116,9 +116,9 @@ public function testValidChoiceCallbackClosure()
$this->validator->validate('bar', $constraint);
}
- public function testValidChoiceCallbackStaticMethod()
+ public function testValidOneOfCallbackStaticMethod()
{
- $constraint = new Choice(array('callback' => array(__CLASS__, 'staticCallback')));
+ $constraint = new OneOf(array('callback' => array(__CLASS__, 'staticCallback')));
$this->context->expects($this->never())
->method('addViolation');
@@ -126,9 +126,9 @@ public function testValidChoiceCallbackStaticMethod()
$this->validator->validate('bar', $constraint);
}
- public function testValidChoiceCallbackContextMethod()
+ public function testValidOneOfCallbackContextMethod()
{
- $constraint = new Choice(array('callback' => 'staticCallback'));
+ $constraint = new OneOf(array('callback' => 'staticCallback'));
$this->context->expects($this->never())
->method('addViolation');
@@ -136,9 +136,9 @@ public function testValidChoiceCallbackContextMethod()
$this->validator->validate('bar', $constraint);
}
- public function testMultipleChoices()
+ public function testMultipleOneOfChoices()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array('foo', 'bar', 'baz'),
'multiple' => true,
));
@@ -149,9 +149,9 @@ public function testMultipleChoices()
$this->validator->validate(array('baz', 'bar'), $constraint);
}
- public function testInvalidChoice()
+ public function testInvalidOneOf()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array('foo', 'bar'),
'message' => 'myMessage',
));
@@ -165,9 +165,9 @@ public function testInvalidChoice()
$this->validator->validate('baz', $constraint);
}
- public function testInvalidChoiceMultiple()
+ public function testInvalidOneOfMultiple()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array('foo', 'bar'),
'multipleMessage' => 'myMessage',
'multiple' => true,
@@ -182,9 +182,9 @@ public function testInvalidChoiceMultiple()
$this->validator->validate(array('foo', 'baz'), $constraint);
}
- public function testTooFewChoices()
+ public function testTooFewOneOfChoices()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array('foo', 'bar', 'moo', 'maa'),
'multiple' => true,
'min' => 2,
@@ -200,9 +200,9 @@ public function testTooFewChoices()
$this->validator->validate(array('foo'), $constraint);
}
- public function testTooManyChoices()
+ public function testTooManyOneOfChoices()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array('foo', 'bar', 'moo', 'maa'),
'multiple' => true,
'max' => 2,
@@ -220,7 +220,7 @@ public function testTooManyChoices()
public function testNonStrict()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array(1, 2),
'strict' => false,
));
@@ -234,7 +234,7 @@ public function testNonStrict()
public function testStrictAllowsExactValue()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array(1, 2),
'strict' => true,
));
@@ -247,7 +247,7 @@ public function testStrictAllowsExactValue()
public function testStrictDisallowsDifferentType()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array(1, 2),
'strict' => true,
'message' => 'myMessage'
@@ -262,9 +262,9 @@ public function testStrictDisallowsDifferentType()
$this->validator->validate('2', $constraint);
}
- public function testNonStrictWithMultipleChoices()
+ public function testNonStrictOneOfWithMultipleChoices()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array(1, 2, 3),
'multiple' => true,
'strict' => false
@@ -276,9 +276,9 @@ public function testNonStrictWithMultipleChoices()
$this->validator->validate(array('2', 3), $constraint);
}
- public function testStrictWithMultipleChoices()
+ public function testStrictOneOfWithMultipleChoices()
{
- $constraint = new Choice(array(
+ $constraint = new OneOf(array(
'choices' => array(1, 2, 3),
'multiple' => true,
'strict' => true,
Something went wrong with that request. Please try again.