Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-300: Added timezone offset to timestamp #181

Merged
merged 9 commits into from
May 12, 2021
31 changes: 19 additions & 12 deletions eZ/Publish/API/Repository/Tests/FieldType/DateIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ public function getInvalidValidatorConfiguration()
*/
public function getValidCreationFieldData()
{
// We may only create times from timestamps here, since storing will
// loose information about the timezone.
return DateValue::fromTimestamp(86400);
$dateTime = $this->getValueOneDate();

return DateValue::fromTimestamp($dateTime->getTimestamp());
}

/**
Expand Down Expand Up @@ -147,8 +147,7 @@ public function assertFieldDataLoadedCorrect(Field $field)
$field->value
);

$dateTime = new DateTime();
$dateTime->setTimestamp(86400)->setTime(0, 0, 0);
$dateTime = $this->getValueOneDate();

$expectedData = [
'date' => $dateTime,
Expand Down Expand Up @@ -198,7 +197,9 @@ public function provideInvalidCreationFieldData()
*/
public function getValidUpdateFieldData()
{
return DateValue::fromTimestamp(86400);
$dateTime = $this->getValueOneDate();

return DateValue::fromTimestamp($dateTime->getTimestamp());
}

/**
Expand All @@ -216,8 +217,7 @@ public function assertUpdatedFieldDataLoadedCorrect(Field $field)
$field->value
);

$dateTime = new DateTime();
$dateTime->setTimestamp(86400)->setTime(0, 0, 0);
$dateTime = $this->getValueOneDate();

$expectedData = [
'date' => $dateTime,
Expand Down Expand Up @@ -367,16 +367,15 @@ public function providerForTestIsNotEmptyValue()

protected function getValidSearchValueOne()
{
$dateTime = new DateTime();
$dateTime->setTimestamp(86400)->setTime(0, 0, 0);
$dateTime = $this->getValueOneDate();

return $dateTime->getTimestamp();
}

protected function getValidSearchValueTwo()
{
$dateTime = new DateTime();
$dateTime->setTimestamp(172800)->setTime(0, 0, 0);
$dateTime = new DateTime('1970-01-03');
$dateTime->setTime(0, 0, 0);

return $dateTime->getTimestamp();
}
Expand All @@ -400,4 +399,12 @@ protected function getSearchTargetValueTwo()

return '1970-01-03T00:00:00Z';
}

protected function getValueOneDate(): DateTime
{
$dateTime = new DateTime('1970-01-02');
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved
$dateTime->setTime(0, 0, 0);

return $dateTime;
}
}