@@ -5064,7 +5064,7 @@ public function testBulkDocumentDateOperations(): void
50645064 // Test 5: Bulk upsert operations with custom dates
50655065 $ database ->setPreserveDates (true );
50665066
5067- // Test 5.1 : Bulk upsert with different date configurations
5067+ // Test 6 : Bulk upsert with different date configurations
50685068 $ upsertDocuments = [
50695069 new Document ([
50705070 '$id ' => 'upsert1 ' ,
@@ -5097,7 +5097,7 @@ public function testBulkDocumentDateOperations(): void
50975097 $ upsertResults [] = $ doc ;
50985098 });
50995099
5100- // Verify initial upsert state
5100+ // Test 7: Verify initial upsert state
51015101 foreach (['upsert1 ' , 'upsert3 ' ] as $ id ) {
51025102 $ doc = $ database ->getDocument ($ collection , $ id );
51035103 $ this ->assertEquals ($ createDate , $ doc ->getAttribute ('$createdAt ' ), "createdAt mismatch for $ id " );
@@ -5114,7 +5114,7 @@ public function testBulkDocumentDateOperations(): void
51145114 $ this ->assertNotEmpty ($ doc ->getAttribute ('$updatedAt ' ), "updatedAt missing for $ id " );
51155115 }
51165116
5117- // Test 5.2 : Bulk upsert update with custom dates using updateDocuments
5117+ // Test 8 : Bulk upsert update with custom dates using updateDocuments
51185118 $ newDate = '2000-04-01T12:00:00.000+00:00 ' ;
51195119 $ updateUpsertDoc = new Document ([
51205120 'string ' => 'upsert_updated ' ,
@@ -5139,7 +5139,30 @@ public function testBulkDocumentDateOperations(): void
51395139 $ this ->assertEquals ('upsert_updated ' , $ doc ->getAttribute ('string ' ), "string mismatch for $ id " );
51405140 }
51415141
5142- // Test 5.3: Bulk upsert operations with createOrUpdateDocuments
5142+ // Test 9: checking by passing null to each
5143+ $ updateUpsertDoc = new Document ([
5144+ 'string ' => 'upsert_updated ' ,
5145+ '$createdAt ' => null ,
5146+ '$updatedAt ' => null
5147+ ]);
5148+
5149+ $ upsertIds = [];
5150+ foreach ($ upsertDocuments as $ doc ) {
5151+ $ upsertIds [] = $ doc ->getId ();
5152+ }
5153+
5154+ $ countUpsert = $ database ->updateDocuments ($ collection , $ updateUpsertDoc , [
5155+ Query::equal ('$id ' , $ upsertIds )
5156+ ]);
5157+ $ this ->assertEquals (4 , $ countUpsert );
5158+
5159+ foreach ($ upsertIds as $ id ) {
5160+ $ doc = $ database ->getDocument ($ collection , $ id );
5161+ $ this ->assertNotEmpty ($ doc ->getAttribute ('$createdAt ' ), "createdAt mismatch for $ id " );
5162+ $ this ->assertNotEmpty ($ doc ->getAttribute ('$updatedAt ' ), "updatedAt mismatch for $ id " );
5163+ }
5164+
5165+ // Test 10: Bulk upsert operations with createOrUpdateDocuments
51435166 $ upsertUpdateDocuments = [];
51445167 foreach ($ upsertDocuments as $ doc ) {
51455168 $ updatedDoc = clone $ doc ;
@@ -5161,7 +5184,7 @@ public function testBulkDocumentDateOperations(): void
51615184 $ this ->assertEquals ('upsert_updated_via_upsert ' , $ doc ->getAttribute ('string ' ), "string mismatch for upsert update " );
51625185 }
51635186
5164- // Test 5.4 : Bulk upsert with preserve dates disabled
5187+ // Test 11 : Bulk upsert with preserve dates disabled
51655188 $ database ->setPreserveDates (false );
51665189
51675190 $ customDate = 'should be ignored anyways so no error ' ;
0 commit comments