Skip to content

Commit 3917f8c

Browse files
Merge branch '6.1' into 6.2
* 6.1: Fix merge Fix wrong handling of null values when Unique::fields is set
2 parents 36ed3db + 14ae584 commit 3917f8c

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/Symfony/Component/HttpClient/Tests/DataCollector/HttpClientDataCollectorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function testItGeneratesCurlCommandsAsExpected(array $request, string $ex
172172
{
173173
$sut = new HttpClientDataCollector();
174174
$sut->registerClient('http_client', $this->httpClientThatHasTracedRequests([$request]));
175-
$sut->collect(new Request(), new Response());
175+
$sut->lateCollect();
176176
$collectedData = $sut->getClients();
177177
self::assertCount(1, $collectedData['http_client']['traces']);
178178
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];
@@ -356,7 +356,7 @@ public function testItDoesNotFollowRedirectionsWhenGeneratingCurlCommands()
356356
],
357357
],
358358
]));
359-
$sut->collect(new Request(), new Response());
359+
$sut->lateCollect();
360360
$collectedData = $sut->getClients();
361361
self::assertCount(1, $collectedData['http_client']['traces']);
362362
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];
@@ -386,7 +386,7 @@ public function testItDoesNotGeneratesCurlCommandsForUnsupportedBodyType()
386386
],
387387
],
388388
]));
389-
$sut->collect(new Request(), new Response());
389+
$sut->lateCollect();
390390
$collectedData = $sut->getClients();
391391
self::assertCount(1, $collectedData['http_client']['traces']);
392392
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];
@@ -408,7 +408,7 @@ public function testItDoesNotGeneratesCurlCommandsForNotEncodableBody()
408408
],
409409
],
410410
]));
411-
$sut->collect(new Request(), new Response());
411+
$sut->lateCollect();
412412
$collectedData = $sut->getClients();
413413
self::assertCount(1, $collectedData['http_client']['traces']);
414414
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];
@@ -430,7 +430,7 @@ public function testItDoesNotGeneratesCurlCommandsForTooBigData()
430430
],
431431
],
432432
]));
433-
$sut->collect(new Request(), new Response());
433+
$sut->lateCollect();
434434
$collectedData = $sut->getClients();
435435
self::assertCount(1, $collectedData['http_client']['traces']);
436436
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];

src/Symfony/Component/Validator/Constraints/UniqueValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private function reduceElementKeys(array $fields, array $element): array
7676
if (!\is_string($field)) {
7777
throw new UnexpectedTypeException($field, 'string');
7878
}
79-
if (isset($element[$field])) {
79+
if (\array_key_exists($field, $element)) {
8080
$output[$field] = $element[$field];
8181
}
8282
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ public function getInvalidCollectionValues(): array
281281
['id' => 1, 'email' => '[email protected]'],
282282
['id' => 1, 'email' => '[email protected]'],
283283
], ['id']],
284+
'unique null' => [
285+
[null, null],
286+
[],
287+
],
288+
'unique field null' => [
289+
[['nullField' => null], ['nullField' => null]],
290+
['nullField'],
291+
],
284292
];
285293
}
286294
}

0 commit comments

Comments
 (0)