8000 fix tests · symfony/symfony@f361e52 · GitHub
[go: up one dir, main page]

Skip to content

Commit f361e52

Browse files
committed
fix tests
1 parent 4884a2e commit f361e52

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ protected function instantiateComplexObject(array &$data, $class, array &$contex
335335
if ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) {
336336
$parameterData = $data[$key];
337337
if (null !== $constructorParameter->getClass()) {
338-
$parameterData = $this->serializer->deserialize($parameterData, $constructorParameter->getClass()->getName(), null, $context);
338+
$parameterData = $this->serializer->deserialize($parameterData, $constructorParameter->getClass()->getName(), $format, $context);
339339
}
340340

341341
// Don't run set for a parameter passed to the constructor
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Tests\Fixtures;
4+
5+
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
6+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
7+
use Symfony\Component\Serializer\SerializerInterface;
8+
9+
/**
10+
* @author Théo FIDRY <theo.fidry@gmail.com>
11+
*/
12+
class DenormalizerDecoratorSerializer implements SerializerInterface
13+
{
14+
private $normalizer;
15+
16+
/**
17+
* @param NormalizerInterface|DenormalizerInterface $normalizer
18+
*/
19+
public function __construct($normalizer)
20+
{
21+
if (false === $normalizer instanceof NormalizerInterface && false === $normalizer instanceof DenormalizerInterface) {
22+
throw new \InvalidArgumentException();
23+
}
24+
25+
$this->normalizer = $normalizer;
26+
}
27+
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
public function serialize($data, $format, array $context = array())
32+
{
33+
return $this->normalizer->normalize($data, $format, $context);
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function deserialize($data, $type, $format, array $context = array())
40+
{
41+
return $this->normalizer->denormalize($data, $type, $format, $context);
42+
}
43+
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Serializer\SerializerInterface;
2222
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2323
use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy;
24+
use Symfony\Component\Serializer\Tests\Fixtures\DenormalizerDecoratorSerializer;
2425
use Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy;
2526
use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder;
2627
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
@@ -167,12 +168,16 @@ public function testConstructorWithObjectTypeHintDenormalize()
167168
),
168169
);
169170

170-
$obj = $this->normalizer->denormalize($data, DummyWithConstructorObject::class);
171+
$normalizer = new ObjectNormalizer();
172+
$serializer = new DenormalizerDecoratorSerializer($normalizer);
173+
$normalizer->setSerializer($serializer);
174+
175+
$obj = $normalizer->denormalize($data, DummyWithConstructorObject::class);
171176
$this->assertInstanceOf(DummyWithConstructorObject::class, $obj);
172-
$this->assertEquals(10, $obj->getId);
177+
$this->assertEquals(10, $obj->getId());
173178
$this->assertInstanceOf(ObjectInner::class, $obj->getInner());
174-
$this->assertEquals('foo', $obj->getInner()->foo);
175-
$this->assertEquals('bar', $obj->getInner()->bar);
179+
$this->assertEquals('oof', $obj->getInner()->foo);
180+
$this->assertEquals('rab', $obj->getInner()->bar);
176181
}
177182

178183
public function testGroupsNormalize()

src/Symfony/Component/Serializer/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.5.9"
19+
"php": ">=5.5.9",
20+
"symfony/property-access": "^3.1"
2021
},
2122
"require-dev": {
2223
"symfony/yaml": "~2.8|~3.0",
2324
"symfony/config": "~2.8|~3.0",
24-
"symfony/property-access": "~2.8|~3.0",
2525
"symfony/http-foundation": "~2.8|~3.0",
2626
"symfony/cache": "~3.1",
2727
"symfony/property-info": "~2.8|~3.0",

0 commit comments

Comments
 (0)
0