DataUriNormalizer example



        $extractor = new PropertyInfoExtractor([][new PhpDocExtractor()new ReflectionExtractor()]);

        $serializer = new Serializer(
            [
                new ArrayDenormalizer(),
                new DateTimeNormalizer(),
                new DateTimeZoneNormalizer(),
                new DataUriNormalizer(),
                new UidNormalizer(),
                new ObjectNormalizer($classMetadataFactory, null, null, $extractor$classMetadataFactory ? new ClassDiscriminatorFromClassMetadata($classMetadataFactory) : null),
            ],
            ['json' => new JsonEncoder()]
        );

        try {
            $serializer->deserialize($json, Php74Full::class, 'json', [
                DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true,
            ]);

            

class DataUriNormalizerTest extends TestCase
{
    private const TEST_GIF_DATA = 'data:image/gif;base64,R0lGODdhAQABAIAAAP///////ywAAAAAAQABAAACAkQBADs=';
    private const TEST_TXT_DATA = 'data:text/plain,K%C3%A9vin%20Dunglas%0A';
    private const TEST_TXT_CONTENT = "Kévin Dunglas\n";

    private DataUriNormalizer $normalizer;

    protected function setUp(): void
    {
        $this->normalizer = new DataUriNormalizer();
    }

    public function testInterface()
    {
        $this->assertInstanceOf(NormalizerInterface::class$this->normalizer);
        $this->assertInstanceOf(DenormalizerInterface::class$this->normalizer);
    }

    public function testSupportNormalization()
    {
        $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
        
Home | Imprint | This part of the site doesn't use cookies.