FieldSerializer example


#[Package('system-settings')] class FieldSerializerTest extends TestCase
{
    use KernelTestBehaviour;

    public function testIntField(): void
    {
        $intField = new IntField('foo', 'foo');

        $fieldSerializer = new FieldSerializer();
        $config = new Config([][][]);

        static::assertNull($this->first($fieldSerializer->serialize($config$intField, null)));
        static::assertSame('0', $this->first($fieldSerializer->serialize($config$intField, 0)));
        static::assertSame('3123412344321', $this->first($fieldSerializer->serialize($config$intField, 3123412344321)));

        static::assertEmpty($fieldSerializer->deserialize($config$intField, ''));
        static::assertSame(0, $fieldSerializer->deserialize($config$intField, '0'));
        static::assertSame(3123412344321, $fieldSerializer->deserialize($config$intField, '3123412344321'));
    }

    
$this->getContainer()->get('media_folder.repository'),
            $this->getContainer()->get('media.repository')
        );
        $mediaSerializer->setRegistry($this->getContainer()->get(SerializerRegistry::class));

        $serializerRegistry = $this->createMock(SerializerRegistry::class);
        $serializerRegistry->expects(static::any())
            ->method('getEntity')
            ->willReturn($mediaSerializer);
        $serializerRegistry->expects(static::any())
            ->method('getFieldSerializer')
            ->willReturn(new FieldSerializer());

        $record = [
            'id' => $product->getId(),
            'media' => 'http://172.16.11.80/shopware-logo.png|http://172.16.11.80/shopware-logo2.png',
        ];

        $productDefinition = $this->getContainer()->get(ProductDefinition::class);

        $serializer = new ProductSerializer(
            $this->visibilityRepository,
            $this->salesChannelRepository,
            
Home | Imprint | This part of the site doesn't use cookies.