Skip to content

Commit 34fd4e4

Browse files
committed
Merge branch '2.5'
* 2.5: [Validator] Fixed missing use statements [Validators] Fixed failing tests requiring ICU 52.1 which are skipped otherwise [FrameworkBundle] Fixed validator factory definition when the Validator API is "auto" for PHP < 5.3.9 return empty metadata collection if none do exist
2 parents a085366 + 1c47fea commit 34fd4e4

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

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

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

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

Tests/Constraints/LanguageValidatorTest.php

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

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

Tests/Constraints/LocaleValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testInvalidLocales($locale)
9090
$this->validator->validate($locale, $constraint);
9191

9292
$this->assertViolation('myMessage', array(
93-
'{{ value }}' => $locale,
93+
'{{ value }}' => '"'.$locale.'"',
9494
));
9595
}
9696

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)