Skip to content

Commit fbd2577

Browse files
committed
Tests fix
1 parent ed2ccc1 commit fbd2577

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Database/Database.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4979,6 +4979,8 @@ public function createOrUpdateDocumentsWithIncrease(
49794979
if ($old->isEmpty()) {
49804980
$createdAt = $document->getCreatedAt();
49814981
$document->setAttribute('$createdAt', empty($createdAt) || !$this->preserveDates ? $time : $createdAt);
4982+
} else {
4983+
$document['$createdAt'] = $old->getCreatedAt();
49824984
}
49834985

49844986
if (!$updatesPermissions) {

tests/e2e/Adapter/Scopes/DocumentTests.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ public function testCreateOrUpdateDocuments(): void
368368

369369
$this->assertEquals(2, $count);
370370

371-
foreach ($results as $document) {
371+
$createdAt = [];
372+
foreach ($results as $index => $document) {
373+
$createdAt[$index] = $document->getCreatedAt();
372374
$this->assertNotEmpty(true, $document->getId());
373375
$this->assertIsString($document->getAttribute('string'));
374376
$this->assertEquals('text📝', $document->getAttribute('string')); // Also makes sure an emoji is working
@@ -398,10 +400,10 @@ public function testCreateOrUpdateDocuments(): void
398400
$documents[1]->setAttribute('integer', 10);
399401

400402
$results = [];
403+
401404
$count = static::getDatabase()->createOrUpdateDocuments(__FUNCTION__, $documents, onNext: function ($doc) use (&$results) {
402405
$results[] = $doc;
403406
});
404-
405407
$this->assertEquals(2, $count);
406408

407409
foreach ($results as $document) {
@@ -418,7 +420,8 @@ public function testCreateOrUpdateDocuments(): void
418420

419421
$this->assertEquals(2, count($documents));
420422

421-
foreach ($documents as $document) {
423+
foreach ($documents as $index => $document) {
424+
$this->assertEquals($createdAt[$index], $document->getCreatedAt());
422425
$this->assertNotEmpty(true, $document->getId());
423426
$this->assertIsString($document->getAttribute('string'));
424427
$this->assertEquals('new text📝', $document->getAttribute('string')); // Also makes sure an emoji is working

0 commit comments

Comments
 (0)