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

Remove depreciate timestamps in DataAndTimeConverter and DateConverter #509

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -61483,7 +61483,7 @@ parameters:
path: tests/lib/Persistence/Legacy/SharedGateway/GatewayFactoryTest.php

-
message: '#^PHPDoc tag @var with type Doctrine\\DBAL\\Platforms\\AbstractPlatform is not subtype of native type Doctrine\\DBAL\\Platforms\\MySqlPlatform\|Doctrine\\DBAL\\Platforms\\PostgreSqlPlatform\|Doctrine\\DBAL\\Platforms\\SqlitePlatform\.$#'
message: '#^PHPDoc tag @var with type Doctrine\\DBAL\\Platforms\\AbstractPlatform is not subtype of native type Doctrine\\DBAL\\Platforms\\MySQL80Platform\|Doctrine\\DBAL\\Platforms\\MySqlPlatform\|Doctrine\\DBAL\\Platforms\\PostgreSqlPlatform\|Doctrine\\DBAL\\Platforms\\SqlitePlatform\.$#'
identifier: varTag.nativeType
count: 1
path: tests/lib/Persistence/Legacy/SharedGateway/GatewayFactoryTest.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefin
case DateAndTimeType::DEFAULT_CURRENT_DATE:
$data = [
'rfc850' => null,
'timestamp' => time(), // @deprecated timestamp is no longer used and will be removed in a future version.
'timestring' => 'now',
];
break;
Expand All @@ -113,7 +112,6 @@ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefin
$date->add($dateInterval);
$data = [
'rfc850' => null,
'timestamp' => $date->getTimestamp(), // @deprecated timestamp is no longer used and will be removed in a future version.
'timestring' => $dateInterval->format('%y years, %m months, %d days, %h hours, %i minutes, %s seconds'),
];
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefin
switch ($fieldDef->fieldTypeConstraints->fieldSettings['defaultType']) {
case DateType::DEFAULT_CURRENT_DATE:
$data = [
'timestamp' => time(), // @deprecated timestamp is no longer used and will be removed in a future version.
'rfc850' => null,
'timestring' => 'now',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ public function testToFieldDefinitionCurrentDate()
$dateTimeFromString = new DateTime($fieldDef->defaultValue->data['timestring']);

self::assertIsArray($fieldDef->defaultValue->data);
self::assertCount(3, $fieldDef->defaultValue->data);
self::assertCount(2, $fieldDef->defaultValue->data);
self::assertNull($fieldDef->defaultValue->data['rfc850']);
self::assertGreaterThanOrEqual($time, $fieldDef->defaultValue->data['timestamp']);
self::assertEqualsWithDelta($time + 1, $dateTimeFromString->getTimestamp(), 1, 'Time does not match within 1s delta');
}

Expand Down Expand Up @@ -276,12 +275,10 @@ public function testToFieldDefinitionWithAdjustmentAndSeconds()
$dateTimeFromString = new DateTime($fieldDef->defaultValue->data['timestring']);

self::assertIsArray($fieldDef->defaultValue->data);
self::assertCount(3, $fieldDef->defaultValue->data);
self::assertCount(2, $fieldDef->defaultValue->data);
self::assertNull($fieldDef->defaultValue->data['rfc850']);
self::assertGreaterThanOrEqual($timestamp, $fieldDef->defaultValue->data['timestamp']);
self::assertGreaterThanOrEqual($timestamp, $dateTimeFromString->getTimestamp());
// Giving a margin of 1 second for test execution
self::assertLessThanOrEqual($timestamp + 1, $fieldDef->defaultValue->data['timestamp']);
self::assertLessThanOrEqual($timestamp + 1, $dateTimeFromString->getTimestamp());
}

Expand Down Expand Up @@ -311,12 +308,10 @@ public function testToFieldDefinitionWithAdjustmentNoSeconds()
$dateTimeFromString = new DateTime($fieldDef->defaultValue->data['timestring']);

self::assertIsArray($fieldDef->defaultValue->data);
self::assertCount(3, $fieldDef->defaultValue->data);
self::assertCount(2, $fieldDef->defaultValue->data);
self::assertNull($fieldDef->defaultValue->data['rfc850']);
self::assertGreaterThanOrEqual($timestamp, $fieldDef->defaultValue->data['timestamp']);
self::assertGreaterThanOrEqual($timestamp, $dateTimeFromString->getTimestamp());
// Giving a margin of 1 second for test execution
self::assertLessThanOrEqual($timestamp + 1, $fieldDef->defaultValue->data['timestamp']);
self::assertLessThanOrEqual($timestamp + 1, $dateTimeFromString->getTimestamp());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public function testToFieldValue()
],
$fieldValue->data
);
self::assertSame($storageFieldValue->dataInt, $fieldValue->data['timestamp']);
self::assertSame($storageFieldValue->sortKeyInt, $fieldValue->sortKey);
}

Expand Down Expand Up @@ -144,9 +143,8 @@ public function testToFieldDefinitionDefaultCurrentDate()

$this->converter->toFieldDefinition($storageDef, $fieldDef);
self::assertIsArray($fieldDef->defaultValue->data);
self::assertCount(3, $fieldDef->defaultValue->data);
self::assertCount(2, $fieldDef->defaultValue->data);
self::assertNull($fieldDef->defaultValue->data['rfc850']);
self::assertSame($timestamp, $fieldDef->defaultValue->data['timestamp']);
self::assertSame('now', $fieldDef->defaultValue->data['timestring']);
}
}
Loading