Skip to content

Commit bed12b7

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: (29 commits) fix tests add missing method fix merge fix test fix merge fix test change test to use a real ObjectManager [Mailer] Document the usage of custom headers in Infobip bridge [SecurityBundle] Add `provider` XML attribute to the authenticators it’s missing from [DoctrineBridge] Test reset with a true manager Sync php-cs-fixer config file with 7.2 [HttpClient] Fix parsing SSE [Notifier] Fix thread key in GoogleChat bridge [HttpKernel][Security] Fix accessing session for stateless request [Serializer] Fix `ObjectNormalizer` with property path test handling of special "value" constraint option [PhpUnitBridge] Add missing import [FrameworkBundle] Fix setting default context for certain normalizers [57251] Missing translations for Romanian (ro) [ErrorHandler] Fix rendered exception code highlighting on PHP 8.3 ...
2 parents fcab759 + 0426605 commit bed12b7

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

Constraints/UniqueValidator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function validate(mixed $value, Constraint $constraint): void
4848

4949
if (\in_array($element, $collectionElements, true)) {
5050
$this->context->buildViolation($constraint->message)
51-
->setParameter('{{ value }}', $this->formatValue($value))
51+
->setParameter('{{ value }}', $this->formatValue($element))
5252
->setCode(Unique::IS_NOT_UNIQUE)
5353
->addViolation();
5454

Resources/translations/validators.ro.xlf

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@
440440
</trans-unit>
441441
<trans-unit id="113">
442442
<source>This URL is missing a top-level domain.</source>
443-
<target state="needs-review-translation">Acest URL îi lipsește un domeniu de nivel superior.</target>
443+
<target>Acestui URL îi lipsește un domeniu de nivel superior.</target>
444444
</trans-unit>
445445
</body>
446446
</file>

Tests/Constraints/CssColorValidatorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public static function getInvalidHSL(): array
403403
}
404404

405405
/**
406-
* @dataProvider getInvalidHSL
406+
* @dataProvider getInvalidHSLA
407407
*/
408408
public function testInvalidHSLA($cssColor)
409409
{

Tests/Constraints/UniqueValidatorTest.php

+18-16
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public static function getValidValues()
6161
/**
6262
* @dataProvider getInvalidValues
6363
*/
64-
public function testInvalidValues($value)
64+
public function testInvalidValues($value, $expectedMessageParam)
6565
{
6666
$constraint = new Unique([
6767
'message' => 'myMessage',
6868
]);
6969
$this->validator->validate($value, $constraint);
7070

7171
$this->buildViolation('myMessage')
72-
->setParameter('{{ value }}', 'array')
72+
->setParameter('{{ value }}', $expectedMessageParam)
7373
->setCode(Unique::IS_NOT_UNIQUE)
7474
->assertRaised();
7575
}
@@ -79,12 +79,12 @@ public static function getInvalidValues()
7979
$object = new \stdClass();
8080

8181
return [
82-
yield 'not unique booleans' => [[true, true]],
83-
yield 'not unique integers' => [[1, 2, 3, 3]],
84-
yield 'not unique floats' => [[0.1, 0.2, 0.1]],
85-
yield 'not unique string' => [['a', 'b', 'a']],
86-
yield 'not unique arrays' => [[[1, 1], [2, 3], [1, 1]]],
87-
yield 'not unique objects' => [[$object, $object]],
82+
yield 'not unique booleans' => [[true, true], 'true'],
83+
yield 'not unique integers' => [[1, 2, 3, 3], 3],
84+
yield 'not unique floats' => [[0.1, 0.2, 0.1], 0.1],
85+
yield 'not unique string' => [['a', 'b', 'a'], '"a"'],
86+
yield 'not unique arrays' => [[[1, 1], [2, 3], [1, 1]], 'array'],
87+
yield 'not unique objects' => [[$object, $object], 'object'],
8888
];
8989
}
9090

@@ -94,7 +94,7 @@ public function testInvalidValueNamed()
9494
$this->validator->validate([1, 2, 3, 3], $constraint);
9595

9696
$this->buildViolation('myMessage')
97-
->setParameter('{{ value }}', 'array')
97+
->setParameter('{{ value }}', '3')
9898
->setCode(Unique::IS_NOT_UNIQUE)
9999
->assertRaised();
100100
}
@@ -174,7 +174,7 @@ public function testExpectsInvalidNonStrictComparison()
174174
]));
175175

176176
$this->buildViolation('myMessage')
177-
->setParameter('{{ value }}', 'array')
177+
->setParameter('{{ value }}', '1')
178178
->setCode(Unique::IS_NOT_UNIQUE)
179179
->assertRaised();
180180
}
@@ -200,7 +200,7 @@ public function testExpectsInvalidCaseInsensitiveComparison()
200200
]));
201201

202202
$this->buildViolation('myMessage')
203-
->setParameter('{{ value }}', 'array')
203+
->setParameter('{{ value }}', '"hello"')
204204
->setCode(Unique::IS_NOT_UNIQUE)
205205
->assertRaised();
206206
}
@@ -246,14 +246,14 @@ public static function getInvalidFieldNames(): array
246246
/**
247247
* @dataProvider getInvalidCollectionValues
248248
*/
249-
public function testInvalidCollectionValues(array $value, array $fields)
249+
public function testInvalidCollectionValues(array $value, array $fields, string $expectedMessageParam)
250250
{
251251
$this->validator->validate($value, new Unique([
252252
'message' => 'myMessage',
253253
], fields: $fields));
254254

255255
$this->buildViolation('myMessage')
256-
->setParameter('{{ value }}', 'array')
256+
->setParameter('{{ value }}', $expectedMessageParam)
257257
->setCode(Unique::IS_NOT_UNIQUE)
258258
->assertRaised();
259259
}
@@ -264,23 +264,25 @@ public static function getInvalidCollectionValues(): array
264264
'unique string' => [[
265265
['lang' => 'eng', 'translation' => 'hi'],
266266
['lang' => 'eng', 'translation' => 'hello'],
267-
], ['lang']],
267+
], ['lang'], 'array'],
268268
'unique floats' => [[
269269
['latitude' => 51.509865, 'longitude' => -0.118092, 'poi' => 'capital'],
270270
['latitude' => 52.520008, 'longitude' => 13.404954],
271271
['latitude' => 51.509865, 'longitude' => -0.118092],
272-
], ['latitude', 'longitude']],
272+
], ['latitude', 'longitude'], 'array'],
273273
'unique int' => [[
274274
['id' => 1, 'email' => '[email protected]'],
275275
['id' => 1, 'email' => '[email protected]'],
276-
], ['id']],
276+
], ['id'], 'array'],
277277
'unique null' => [
278278
[null, null],
279279
[],
280+
'null',
280281
],
281282
'unique field null' => [
282283
[['nullField' => null], ['nullField' => null]],
283284
['nullField'],
285+
'array',
284286
],
285287
];
286288
}

0 commit comments

Comments
 (0)