minor #11707 [Validator] Test that validateProperty() works if no constraint is defined (xabbuh)

This PR was merged into the 2.5 branch.

Discussion
----------

[Validator] Test that validateProperty() works if no constraint is defined

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes (2.3 has to be merged into 2.5 first)
| Fixed tickets | #11604, #11614
| License       | MIT
| Doc PR        |

Adds a test case for #11604 to avoid regressions. The actual issue has been fixed in Symfony 2.3 with the merge of #11615.

Commits
-------

a47a884 add test for #11604
This commit is contained in:
Fabien Potencier 2014-08-31 05:34:15 +02:00
commit 94990a2769
1 changed files with 22 additions and 0 deletions

View File

@ -851,6 +851,17 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
$this->validateProperty('VALUE', 'someProperty');
}
/**
* https://github.com/symfony/symfony/issues/11604
*/
public function testValidatePropertyWithoutConstraints()
{
$entity = new Entity();
$violations = $this->validateProperty($entity, 'lastName');
$this->assertCount(0, $violations, '->validateProperty() returns no violations if no constraints have been configured for the property being validated');
}
public function testValidatePropertyValue()
{
$test = $this;
@ -970,6 +981,17 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
$this->validatePropertyValue('VALUE', 'someProperty', 'someValue');
}
/**
* https://github.com/symfony/symfony/issues/11604
*/
public function testValidatePropertyValueWithoutConstraints()
{
$entity = new Entity();
$violations = $this->validatePropertyValue($entity, 'lastName', 'foo');
$this->assertCount(0, $violations, '->validatePropertyValue() returns no violations if no constraints have been configured for the property being validated');
}
public function testValidateObjectOnlyOncePerGroup()
{
$entity = new Entity();