Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpoulain committed Apr 3, 2020
1 parent bb99e1c commit 03bd90a
Showing 1 changed file with 20 additions and 0 deletions.
Expand Up @@ -163,6 +163,14 @@ public function testDenormalizeStringCollectionDecodedFromXmlWithTwoChildren()
$this->assertEquals('bar', $stringCollection->children[1]);
}

public function testDenormalizeNotSerializableObjectToPopulate()
{
$normalizer = new AbstractObjectNormalizerDummy();
$normalizedData = $normalizer->denormalize(['foo' => 'foo'], Dummy::class, null, [AbstractObjectNormalizer::OBJECT_TO_POPULATE => new NotSerializable()]);

$this->assertSame('foo', $normalizedData->foo);
}

private function getDenormalizerForStringCollection()
{
$extractor = $this->getMockBuilder(PhpDocExtractor::class)->getMock();
Expand Down Expand Up @@ -379,3 +387,15 @@ public function setSerializer(SerializerInterface $serializer)
$this->serializer = $serializer;
}
}

class NotSerializable
{
public function __sleep()
{
if (class_exists(\Error::class)) {
throw new \Error('not serializable');
}

throw new \Exception('not serializable');
}
}

0 comments on commit 03bd90a

Please sign in to comment.