eZ\Publish\Core\Persistence\Legacy\Tests\Content\FieldValue\Converter\DateAndTimeTest::testToFieldDefinitionWithAdjustmentAndSeconds PHP Method

testToFieldDefinitionWithAdjustmentAndSeconds() public method

    public function testToFieldDefinitionWithAdjustmentAndSeconds()
    {
        $fieldDef = new PersistenceFieldDefinition();
        $dateInterval = DateInterval::createFromDateString('2 years, 1 month, -4 days, 2 hours, 0 minute, 34 seconds');
        $date = new DateTime();
        $date->add($dateInterval);
        $timestamp = $date->getTimestamp();
        $storageDef = new StorageFieldDefinition(array('dataInt1' => DateAndTimeType::DEFAULT_CURRENT_DATE_ADJUSTED, 'dataInt2' => 1, 'dataText5' => $this->getXMLStringFromDateInterval($dateInterval)));
        $this->converter->toFieldDefinition($storageDef, $fieldDef);
        self::assertInternalType('array', $fieldDef->defaultValue->data);
        self::assertCount(2, $fieldDef->defaultValue->data);
        self::assertNull($fieldDef->defaultValue->data['rfc850']);
        self::assertGreaterThanOrEqual($timestamp, $fieldDef->defaultValue->data['timestamp']);
        // Giving a margin of 1 second for test execution
        self::assertLessThanOrEqual($timestamp + 1, $fieldDef->defaultValue->data['timestamp']);
    }