ObjectNormalizer example

static::assertEquals(['bar']$offset->getLanguages());
        static::assertTrue($offset->hasNextLanguage());
        $offset->selectNextLanguage();
        static::assertEquals('bar', $offset->getLanguageId());
        static::assertFalse($offset->hasNextLanguage());
    }

    public function testSerialize(): void
    {
        $serialize = new Serializer(
            [
                new ObjectNormalizer(),
            ],
            [
                new JsonEncoder(null),
            ]
        );

        $before = new IndexerOffset(
            ['foo', 'bar'],
            ['product', 'product_manufacturer'],
            (new \DateTime())->getTimestamp()
        );
        
$versionContext = $context->createWithVersionId(Uuid::randomHex());

        static::assertNotNull($versionContext->getExtension('foo'));
    }

    public function testExtensionsAreStripped(): void
    {
        $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
        $discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);

        $normalizers = [new StructNormalizer()new ObjectNormalizer($classMetadataFactory, null, null, null, $discriminator)new ArrayDenormalizer()];
        $serializer = new Serializer($normalizers[new JsonEncoder()]);

        $context = Context::createDefaultContext();

        $context->addExtension('foo', new ArrayEntity());

        $serialized = $serializer->serialize($context, 'json');
        $deserialized = $serializer->deserialize($serialized, Context::class, 'json');

        static::assertInstanceOf(Context::class$deserialized);

        

    public function testSerialize(): void
    {
        $serializer = new Serializer(
            [
                new SendEmailMessageJsonSerializer(),
            ],
            [
                new JsonEncoder(null),
            ]
        );
        $withoutSerializer = new Serializer([new ObjectNormalizer()][new JsonEncoder(null)]);

        $sendMail = new SendEmailMessage(
            new RawMessage('test'),
            null
        );

        $our = $serializer->serialize($sendMail, 'json');
        $their = $withoutSerializer->serialize($sendMail, 'json');

        static::assertNotEquals($our$their);
    }

    
Home | Imprint | This part of the site doesn't use cookies.