Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59cd05f

Browse files
committed
Merge branch '2.4' into 2.5
* 2.4: [Validators] Fixed failing tests requiring ICU 52.1 which are skipped otherwise return empty metadata collection if none do exist
2 parents bb9552f + 9c69d70 commit 59cd05f

File tree

6 files changed

+28
-6
lines changed

6 files changed

+28
-6
lines changed

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ public function hasMemberMetadatas($property)
371371
*/
372372
public function getMemberMetadatas($property)
373373
{
374+
if (!isset($this->members[$property])) {
375+
return array();
376+
}
377+
374378
return $this->members[$property];
375379
}
376380

@@ -387,6 +391,10 @@ public function hasPropertyMetadata($property)
387391
*/
388392
public function getPropertyMetadata($property)
389393
{
394+
if (!isset($this->members[$property])) {
395+
return array();
396+
}
397+
390398
return $this->members[$property];
391399
}
392400

src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testInvalidCountries($country)
8888
$this->validator->validate($country, $constraint);
8989

9090
$this->assertViolation('myMessage', array(
91-
'{{ value }}' => $country,
91+
'{{ value }}' => '"'.$country.'"',
9292
));
9393
}
9494

src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testInvalidCurrencies($currency)
102102
$this->validator->validate($currency, $constraint);
103103

104104
$this->assertViolation('myMessage', array(
105-
'{{ value }}' => $currency,
105+
'{{ value }}' => '"'.$currency.'"',
106106
));
107107
}
108108

src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Intl\Util\IntlTestHelper;
1515
use Symfony\Component\Validator\Constraints\Language;
1616
use Symfony\Component\Validator\Constraints\LanguageValidator;
17-
use Symfony\Component\Validator\Validation;
1817

1918
class LanguageValidatorTest extends AbstractConstraintValidatorTest
2019
{
@@ -88,7 +87,7 @@ public function testInvalidLanguages($language)
8887
$this->validator->validate($language, $constraint);
8988

9089
$this->assertViolation('myMessage', array(
91-
'{{ value }}' => $language,
90+
'{{ value }}' => '"'.$language.'"',
9291
));
9392
}
9493

src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Intl\Util\IntlTestHelper;
1515
use Symfony\Component\Validator\Constraints\Locale;
1616
use Symfony\Component\Validator\Constraints\LocaleValidator;
17-
use Symfony\Component\Validator\Validation;
1817

1918
class LocaleValidatorTest extends AbstractConstraintValidatorTest
2019
{
@@ -90,7 +89,7 @@ public function testInvalidLocales($locale)
9089
$this->validator->validate($locale, $constraint);
9190

9291
$this->assertViolation('myMessage', array(
93-
'{{ value }}' => $locale,
92+
'{{ value }}' => '"'.$locale.'"',
9493
));
9594
}
9695

src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,20 @@ public function testGroupSequenceProvider()
220220
$metadata->setGroupSequenceProvider(true);
221221
$this->assertTrue($metadata->isGroupSequenceProvider());
222222
}
223+
224+
/**
225+
* https://github.com/symfony/symfony/issues/11604
226+
*/
227+
public function testGetMemberMetadatasReturnsEmptyArrayWithoutConfiguredMetadata()
228+
{
229+
$this->assertCount(0, $this->metadata->getMemberMetadatas('foo'), '->getMemberMetadatas() returns an empty collection if no metadata is configured for the given property');
230+
}
231+
232+
/**
233+
* https://github.com/symfony/symfony/issues/11604
234+
*/
235+
public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadata()
236+
{
237+
$this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property');
238+
}
223239
}

0 commit comments

Comments
 (0)