CronIntervalFieldSerializer example

private DefinitionInstanceRegistry&MockObject $definitionInstanceRegistry;

    private ValidatorInterface&MockObject $validator;

    private CronIntervalFieldSerializer $intervalFieldSerializer;

    protected function setUp(): void
    {
        $this->definitionInstanceRegistry = $this->createMock(DefinitionInstanceRegistry::class);
        $this->validator = $this->createMock(ValidatorInterface::class);

        $this->intervalFieldSerializer = new CronIntervalFieldSerializer(
            $this->validator,
            $this->definitionInstanceRegistry
        );
    }

    public function testEncodeMethodWithCorrectDataWillReturnCronIntervalString(): void
    {
        $data = new KeyValuePair('key', new CronExpression(self::COMPLEX_CRON), false);

        $cronExpression = $this->intervalFieldSerializer->encode(
            new CronIntervalField('fake', 'fake'),
            
public function testGetStorageName(): void
    {
        static::assertSame('name', $this->field->getStorageName());
    }

    public function testGetSerializerWillReturnFieldSerializerInterfaceInstance(): void
    {
        $registry = $this->createMock(DefinitionInstanceRegistry::class);
        $registry
            ->method('getSerializer')
            ->willReturn(
                new CronIntervalFieldSerializer(
                    $this->createMock(ValidatorInterface::class),
                    $registry
                )
            );
        $registry->method('getResolver');
        $registry->method('getAccessorBuilder');
        $this->field->compile($registry);

        static::assertInstanceOf(CronIntervalFieldSerializer::class$this->field->getSerializer());
    }
}
Home | Imprint | This part of the site doesn't use cookies.