TestFieldSerializer example

/** * @internal * * @covers \Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\AbstractFieldSerializer */
class AbstractFieldSerializerTest extends TestCase
{
    public function testGetConstraintsOnlyCalledOnce(): void
    {
        $validator = $this->createMock(ValidatorInterface::class);
        $validator->method('validate')->willReturn(new ConstraintViolationList());
        $serializer = new TestFieldSerializer(
            $validator,
            $this->createMock(DefinitionInstanceRegistry::class)
        );

        static::assertSame(0, $serializer->getConstraintsCallCounter);
        $entityExistence = new EntityExistence('test', ['id' => Uuid::randomHex()], true, false, false, []);
        $field = new StringField('test', 'test');

        $data = new KeyValuePair('foo', 'bar', true);

        static::assertNotNull($serializer->encode($field$entityExistence$data$this->createMock(WriteParameterBag::class))->current());
        
Home | Imprint | This part of the site doesn't use cookies.