diff --git a/src/Symfony/Component/Validator/GraphWalker.php b/src/Symfony/Component/Validator/GraphWalker.php index 489605b1d1..f06d10b9fe 100644 --- a/src/Symfony/Component/Validator/GraphWalker.php +++ b/src/Symfony/Component/Validator/GraphWalker.php @@ -68,8 +68,7 @@ class GraphWalker $initializer->initialize($object); } - if ($group === Constraint::DEFAULT_GROUP && ($metadata->hasGroupSequence() || $metadata->hasGroupSequenceProvider())) { - + if ($group === Constraint::DEFAULT_GROUP && ($metadata->hasGroupSequence() || $metadata->isGroupSequenceProvider())) { if ($metadata->hasGroupSequence()) { $groups = $metadata->getGroupSequence(); } else { diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 5c258dd2e4..2d8c60f098 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -249,7 +249,7 @@ class ClassMetadata extends ElementMetadata */ public function setGroupSequence(array $groups) { - if ($this->hasGroupSequenceProvider()) { + if ($this->isGroupSequenceProvider()) { throw new GroupDefinitionException('Defining a static group sequence is not allowed with a group sequence provider'); } @@ -319,11 +319,11 @@ class ClassMetadata extends ElementMetadata } /** - * Returns whether the class has a group sequence provider. + * Returns whether the class is a group sequence provider. * * @return boolean */ - public function hasGroupSequenceProvider() + public function isGroupSequenceProvider() { return $this->groupSequenceProvider; } diff --git a/tests/Symfony/Tests/Component/Validator/Fixtures/Entity.php b/tests/Symfony/Tests/Component/Validator/Fixtures/Entity.php index e6c6316930..781e41af70 100644 --- a/tests/Symfony/Tests/Component/Validator/Fixtures/Entity.php +++ b/tests/Symfony/Tests/Component/Validator/Fixtures/Entity.php @@ -6,7 +6,6 @@ require_once __DIR__.'/EntityParent.php'; require_once __DIR__.'/EntityInterface.php'; use Symfony\Component\Validator\Constraints as Assert; -use Symfony\Component\Validator\GroupSequenceProviderInterface; /** * @Symfony\Tests\Component\Validator\Fixtures\ConstraintA @@ -29,8 +28,6 @@ class Entity extends EntityParent implements EntityInterface protected $lastName; public $reference; - protected $groups = array(); - private $internal; public function __construct($internal = null) diff --git a/tests/Symfony/Tests/Component/Validator/Mapping/ClassMetadataTest.php b/tests/Symfony/Tests/Component/Validator/Mapping/ClassMetadataTest.php index a3f68f8f30..7da676aba8 100644 --- a/tests/Symfony/Tests/Component/Validator/Mapping/ClassMetadataTest.php +++ b/tests/Symfony/Tests/Component/Validator/Mapping/ClassMetadataTest.php @@ -193,42 +193,39 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase $this->metadata->setGroupSequence(array('Foo', $this->metadata->getDefaultGroup(), Constraint::DEFAULT_GROUP)); } - public function testGroupSequenceFailesIfGroupSequenceProviderIsSet() + /** + * @expectedException Symfony\Component\Validator\Exception\GroupDefinitionException + */ + public function testGroupSequenceFailsIfGroupSequenceProviderIsSet() { $metadata = new ClassMetadata(self::PROVIDERCLASS); $metadata->setGroupSequenceProvider(true); - - try { - $metadata->setGroupSequence(array('GroupSequenceProviderEntity', 'Foo')); - $this->fail(); - } catch(GroupDefinitionException $e) {} + $metadata->setGroupSequence(array('GroupSequenceProviderEntity', 'Foo')); } - public function testGroupSequenceProviderFailesIfGroupSequenceIsSet() + /** + * @expectedException Symfony\Component\Validator\Exception\GroupDefinitionException + */ + public function testGroupSequenceProviderFailsIfGroupSequenceIsSet() { $metadata = new ClassMetadata(self::PROVIDERCLASS); $metadata->setGroupSequence(array('GroupSequenceProviderEntity', 'Foo')); - - try { - $metadata->setGroupSequenceProvider(true); - $this->fail(); - } catch(GroupDefinitionException $e) {} + $metadata->setGroupSequenceProvider(true); } - public function testGroupSequenceProviderFailesIfDomainClassIsInvalid() + /** + * @expectedException Symfony\Component\Validator\Exception\GroupDefinitionException + */ + public function testGroupSequenceProviderFailsIfDomainClassIsInvalid() { $metadata = new ClassMetadata('stdClass'); - - try { - $metadata->setGroupSequenceProvider(true); - $this->fail(); - } catch(GroupDefinitionException $e) {} + $metadata->setGroupSequenceProvider(true); } public function testGroupSequenceProvider() { $metadata = new ClassMetadata(self::PROVIDERCLASS); $metadata->setGroupSequenceProvider(true); - $this->assertTrue($metadata->hasGroupSequenceProvider()); + $this->assertTrue($metadata->isGroupSequenceProvider()); } }