forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Validator] Improved error messages displayed when the Valid constrai…
…nt is misused
- Loading branch information
Showing
10 changed files
with
235 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Symfony/Component/Validator/Tests/Constraints/AllTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Allator\Tests\Constraints; | ||
|
||
use Symfony\Component\Validator\Constraints\All; | ||
use Symfony\Component\Validator\Constraints\Valid; | ||
|
||
/** | ||
* @author Bernhard Schussek <[email protected]> | ||
*/ | ||
class AllTest extends \PHPUnit_Framework_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(), | ||
)); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Collectionator\Tests\Constraints; | ||
|
||
use Symfony\Component\Validator\Constraints\Collection; | ||
use Symfony\Component\Validator\Constraints\Collection\Required; | ||
use Symfony\Component\Validator\Constraints\Collection\Optional; | ||
use Symfony\Component\Validator\Constraints\Valid; | ||
|
||
/** | ||
* @author Bernhard Schussek <[email protected]> | ||
*/ | ||
class CollectionTest extends \PHPUnit_Framework_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()), | ||
)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Symfony/Component/Validator/Tests/Constraints/ValidTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* 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\Valid; | ||
|
||
/** | ||
* @author Bernhard Schussek <[email protected]> | ||
*/ | ||
class ValidTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @expectedException Symfony\Component\Validator\Exception\ConstraintDefinitionException | ||
*/ | ||
public function testRejectGroupsOption() | ||
{ | ||
new Valid(array('groups' => 'foo')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters