Skip to content

Commit 9e37816

Browse files
committed
Support null as an uploadDate in test codec
1 parent c1a297b commit 9e37816

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/GridFS/WritableStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function __construct(CollectionWrapper $collectionWrapper, string $filena
137137
'chunkSize' => $this->chunkSize,
138138
'filename' => $filename,
139139
'length' => 0,
140-
'uploadDate' => new UTCDateTime(0),
140+
'uploadDate' => null,
141141
] + array_intersect_key($options, ['aliases' => 1, 'contentType' => 1, 'metadata' => 1]);
142142
}
143143

tests/Fixtures/Codec/TestFileCodec.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ public function decode($value): TestFile
3131
$fileObject->id = $value->get('_id');
3232
$fileObject->length = (int) $value->get('length');
3333
$fileObject->chunkSize = (int) $value->get('chunkSize');
34-
$fileObject->uploadDate = DateTimeImmutable::createFromMutable($value->get('uploadDate')->toDateTime());
3534
$fileObject->filename = $value->get('filename');
3635

36+
$uploadDate = $value->get('uploadDate');
37+
$fileObject->uploadDate = $uploadDate ? DateTimeImmutable::createFromMutable($uploadDate->toDateTime()) : null;
38+
3739
if ($value->has('metadata')) {
3840
$fileObject->metadata = $value->get('metadata');
3941
}

tests/Fixtures/Document/TestFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class TestFile
2424
public $id;
2525
public int $length;
2626
public int $chunkSize;
27-
public DateTimeImmutable $uploadDate;
27+
public ?DateTimeImmutable $uploadDate = null;
2828
public string $filename;
2929
public $metadata;
3030
}

0 commit comments

Comments
 (0)