Skip to content

Commit eda1dfc

Browse files
committed
add test
1 parent 4b3dcf1 commit eda1dfc

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,24 @@ public function testNormalizationWithMaxDepthOnStdclassObjectDoesNotThrowWarning
11291129

11301130
$this->assertSame(['string' => 'yes'], $normalized);
11311131
}
1132+
1133+
public function testDenormalizeCollectionOfScalarTypesPropertyWithPhpDocExtractor()
1134+
{
1135+
$normalizer = new AbstractObjectNormalizerWithMetadataAndPhpDocExtractor();
1136+
$data = [
1137+
'type' => 'foo',
1138+
'values' => [
1139+
['1'],
1140+
['2'],
1141+
['3'],
1142+
['4'],
1143+
['5'],
1144+
],
1145+
];
1146+
$expected = new ScalarCollectionDocBlockDummy([[1], [2], [3], [4], [5]]);
1147+
1148+
$this->assertEquals($expected, $normalizer->denormalize($data, ScalarCollectionDocBlockDummy::class));
1149+
}
11321150
}
11331151

11341152
class AbstractObjectNormalizerDummy extends AbstractObjectNormalizer
@@ -1540,3 +1558,44 @@ public function __construct(
15401558
) {
15411559
}
15421560
}
1561+
1562+
#[DiscriminatorMap('type', ['foo' => ScalarCollectionDocBlockDummy::class])]
1563+
class ScalarCollectionDocBlockDummy
1564+
{
1565+
/**
1566+
* @param array<int, array<int, string>>|null $values
1567+
*/
1568+
public function __construct(
1569+
private readonly ?array $values = null,
1570+
) {
1571+
}
1572+
/** @return array<int, array<int, string>>|null */
1573+
public function getValues(): ?array
1574+
{
1575+
return $this->values;
1576+
}
1577+
}
1578+
1579+
class AbstractObjectNormalizerWithMetadataAndPhpDocExtractor extends AbstractObjectNormalizer
1580+
{
1581+
public function __construct()
1582+
{
1583+
parent::__construct(new ClassMetadataFactory(new AttributeLoader()), null, new PropertyInfoExtractor([], [new PhpDocExtractor()]));
1584+
}
1585+
1586+
protected function extractAttributes(object $object, ?string $format = null, array $context = []): array
1587+
{
1588+
}
1589+
1590+
protected function getAttributeValue(object $object, string $attribute, ?string $format = null, array $context = []): mixed
1591+
{
1592+
}
1593+
1594+
protected function setAttributeValue(object $object, string $attribute, mixed $value, ?string $format = null, array $context = []): void
1595+
{
1596+
}
1597+
1598+
public function getSupportedTypes(?string $format): array
1599+
{
1600+
}
1601+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy