CronIntervalField example


#[Package('checkout')] class CronIntervalFieldTest extends TestCase
{
    private CronIntervalField $field;

    protected function setUp(): void
    {
        $this->field = new CronIntervalField('name', 'name');
    }

    public function testGetStorageName(): void
    {
        static::assertSame('name', $this->field->getStorageName());
    }

    public function testGetSerializerWillReturnFieldSerializerInterfaceInstance(): void
    {
        $registry = $this->createMock(DefinitionInstanceRegistry::class);
        $registry
            
$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'),
            $this->createStub(EntityExistence::class),
            $data,
            $this->createMock(WriteParameterBag::class)
        )->current();

        static::assertIsString($cronExpression);
        static::assertEquals(self::COMPLEX_CRON, $cronExpression);
    }

    public function testEncodeMethodWithIncorrectFieldParameterTypeWillThrowInvalidSerializerException(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.