CronInterval example

static::assertNull($interval->getReturn());
    }

    public function testDecodeMethodWithCorrectValueWillReturnCronInterval(): void
    {
        $cronInterval = $this->intervalFieldSerializer->decode(
            new CronIntervalField('name', 'name'),
            self::COMPLEX_CRON
        );

        static::assertEquals(new CronInterval(self::COMPLEX_CRON)$cronInterval);
    }

    public function testDecodeMethodWithNoValueWillReturnNull(): void
    {
        $cronInterval = $this->intervalFieldSerializer->decode(
            new CronIntervalField('name', 'name'),
            null
        );

        static::assertNull($cronInterval);
    }

    
/** * @covers \Shopware\Core\Framework\DataAbstractionLayer\FieldType\CronInterval * * @internal */
#[Package('checkout')] class CronIntervalTest extends TestCase
{
    public function testEquals(): void
    {
        $cronInterval = new CronInterval('0 0 * * *');
        $cronInterval2 = new CronInterval('0 0 * * *');
        static::assertTrue($cronInterval->equals($cronInterval2));
    }

    public function testNotEquals(): void
    {
        $cronInterval = new CronInterval('0 0 * * *');
        $cronInterval2 = new CronInterval('0 * * * *');
        static::assertFalse($cronInterval->equals($cronInterval2));
    }

    

    public function decode(Field $field$value): ?CronInterval
    {
        if ($value === null) {
            return null;
        }

        if (!CronInterval::isValidExpression($value)) {
            throw DataAbstractionLayerException::invalidCronIntervalFormat($value);
        }

        return new CronInterval($value);
    }

    protected function getConstraints(Field $field): array
    {
        return [
            new Type(CronExpression::class),
            new NotNull(),
        ];
    }
}
Home | Imprint | This part of the site doesn't use cookies.