8000 added additional unit tests for deserialization · symfony/symfony@cb495fd · GitHub
[go: up one dir, main page]

Skip to content

Commit cb495fd

Browse files
committed
added additional unit tests for deserialization
1 parent 967531f commit cb495fd

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/Symfony/Tests/Component/Serializer/SerializerTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,34 @@ public function testDeserializeWrongNormalizer()
136136
/**
137137
* @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
138138
*/
139-
public function testDeerializeNoEncoder()
139+
public function testDeserializeNoEncoder()
140140
{
141141
$this->serializer = new Serializer(array(), array());
142142
$data = array('title' => 'foo', 'numbers' => array(5, 3));
143143
$this->serializer->deserialize(json_encode($data), '\Symfony\Tests\Component\Serializer\Model', 'json');
144144
}
145145

146+
public function testDeserializeSupported()
147+
{
148+
$this->serializer = new Serializer(array(new GetSetMethodNormalizer()), array());
149+
$data = array('title' => 'foo', 'numbers' => array(5, 3));
150+
$this->assertTrue($this->serializer->supportsDenormalization(json_encode($data), '\Symfony\Tests\Component\Serializer\Model', 'json'));
151+
}
152+
153+
public function testDeserializeNotSupported()
154+
{
155+
$this->serializer = new Serializer(array(new GetSetMethodNormalizer()), array());
156+
$data = array('title' => 'foo', 'numbers' => array(5, 3));
157+
$this->assertFalse($this->serializer->supportsDenormalization(json_encode($data), 'stdClass', 'json'));
158+
}
159+
160+
public function testDeserializeNotSupportedMissing()
161+
{
162+
$this->serializer = new Serializer(array(), array());
163+
$data = array('title' => 'foo', 'numbers' => array(5, 3));
164+
$this->assertFalse($this->serializer->supportsDenormalization(json_encode($data), '\Symfony\Tests\Component\Serializer\Model', 'json'));
165+
}
166+
146167
public function testEncode()
147168
{
148169
$this->serializer = new Serializer(array(), array('json' => new JsonEncoder()));

0 commit comments

Comments
 (0)
0