IBX-11818: added fallback to null value when key 'timestamp' not exists in $value->data array#757
IBX-11818: added fallback to null value when key 'timestamp' not exists in $value->data array#757papcio122 wants to merge 5 commits into
Conversation
…ts in $value->data array
22e8d03 to
f08a3f5
Compare
| * @group fieldType | ||
| * @group dateTime | ||
| */ | ||
| public function testToStorageValueNoTimestampKey(): void |
There was a problem hiding this comment.
We should also test if dataInt is properly populated with the timestamp if it exists.
There was a problem hiding this comment.
There is such a test a few lines earlier on line 47
There was a problem hiding this comment.
I referred to the actual usage of timestamp key which is in the condition in question. How is it covered?
| @@ -32,7 +32,7 @@ public function toStorageValue(FieldValue $value, StorageFieldValue $storageFiel | |||
| { | |||
| // @todo: One should additionally store the timezone here. This could | |||
There was a problem hiding this comment.
If we are SO CLOSE to this. Can we drop that comment? ;)
There was a problem hiding this comment.
Should I just remove it?
Or somehow store the timezone here? 😅
| /** | ||
| * @group fieldType | ||
| * @group dateTime | ||
| */ | ||
| public function testToStorageValueNoTimestampKey(): void | ||
| { | ||
| $value = new FieldValue(); | ||
| $value->data = [ | ||
| 'current_time' => $this->date->getTimestamp(), | ||
| 'rfc850' => $this->date->format(DateTime::RFC850), | ||
| ]; | ||
| $value->sortKey = $this->date->getTimestamp(); | ||
| $storageFieldValue = new StorageFieldValue(); | ||
|
|
||
| $this->converter->toStorageValue($value, $storageFieldValue); | ||
| self::assertNull($storageFieldValue->dataInt); | ||
| self::assertSame($value->sortKey, $storageFieldValue->sortKeyInt); | ||
| self::assertSame('', $storageFieldValue->sortKeyString); | ||
| } | ||
|
|
||
| /** | ||
| * @group fieldType | ||
| * @group dateTime | ||
| */ | ||
| public function testToStorageValueValueDataNull(): void | ||
| { | ||
| $value = new FieldValue(); | ||
| $value->data = null; | ||
| $value->sortKey = $this->date->getTimestamp(); | ||
| $storageFieldValue = new StorageFieldValue(); | ||
|
|
||
| $this->converter->toStorageValue($value, $storageFieldValue); | ||
| self::assertNull($storageFieldValue->dataInt); | ||
| self::assertSame($value->sortKey, $storageFieldValue->sortKeyInt); | ||
| self::assertSame('', $storageFieldValue->sortKeyString); | ||
| } |
There was a problem hiding this comment.
If I see it right, the only difference for these tests is an assignment of $value->data. Can this be a data provider?
| self::assertSame($storageFieldValue->sortKeyInt, $fieldValue->sortKey); | ||
| } | ||
|
|
||
| public function providerForTestToStorageValueMissingData() |
There was a problem hiding this comment.
Please provide a proper return type and PHPStan array shape.
| [ | ||
| 'current_time' => 1048633200, | ||
| 'rfc850' => 'Thu, 01 Jan 2003 00:00:00 GMT', | ||
| ], |
There was a problem hiding this comment.
Do we need to wrap it in several arrays?
b96fb48 to
b95c1c6
Compare
|



Description:
\Ibexa\Core\Persistence\Legacy\Content\FieldValue\Converter\DateAndTimeConverter:toStorageValue()
throws an error of a missing array key when the content was created before the field was added to the content type.
Added fallback to null when the data array has no 'timestamp' key