minor #11615 [Validator] return empty metadata collection if none do exist (xabbuh)
This PR was merged into the 2.3 branch.
Discussion
----------
[Validator] return empty metadata collection if none do exist
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR | [The reference to the documentation PR if any]
Backport of #11614 for Symfony 2.3 and 2.4.
Commits
-------
f5bc18d
return empty metadata collection if none do exist
This commit is contained in:
commit
f825f5d1c3
|
@ -298,6 +298,10 @@ class ClassMetadata extends ElementMetadata implements MetadataInterface, ClassB
|
|||
*/
|
||||
public function getMemberMetadatas($property)
|
||||
{
|
||||
if (!isset($this->members[$property])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $this->members[$property];
|
||||
}
|
||||
|
||||
|
@ -314,6 +318,10 @@ class ClassMetadata extends ElementMetadata implements MetadataInterface, ClassB
|
|||
*/
|
||||
public function getPropertyMetadata($property)
|
||||
{
|
||||
if (!isset($this->members[$property])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $this->members[$property];
|
||||
}
|
||||
|
||||
|
|
|
@ -222,4 +222,20 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
|
|||
$metadata->setGroupSequenceProvider(true);
|
||||
$this->assertTrue($metadata->isGroupSequenceProvider());
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/symfony/symfony/issues/11604
|
||||
*/
|
||||
public function testGetMemberMetadatasReturnsEmptyArrayWithoutConfiguredMetadata()
|
||||
{
|
||||
$this->assertCount(0, $this->metadata->getMemberMetadatas('foo'), '->getMemberMetadatas() returns an empty collection if no metadata is configured for the given property');
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/symfony/symfony/issues/11604
|
||||
*/
|
||||
public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadata()
|
||||
{
|
||||
$this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property');
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue