@@ -388,7 +388,70 @@ public function testCreateDocumentsWithDifferentAttributes(): void
388388 $ database ->deleteCollection ($ collection );
389389 }
390390
391- public function testUpsertDocuments (): void
391+ public function testSkipPermissions (): void
392+ {
393+ /** @var Database $database */
394+ $ database = static ::getDatabase ();
395+
396+ if (!$ database ->getAdapter ()->getSupportForUpserts ()) {
397+ $ this ->expectNotToPerformAssertions ();
398+ return ;
399+ }
400+
401+ $ database ->createCollection (__FUNCTION__ );
402+ $ database ->createAttribute (__FUNCTION__ , 'number ' , Database::VAR_INTEGER , 0 , false );
403+
404+ $ data = [];
405+ for ($ i = 1 ; $ i <= 10 ; $ i ++) {
406+ $ data [] = [
407+ '$id ' => "$ i " ,
408+ 'number ' => $ i ,
409+ ];
410+ }
411+
412+ $ documents = array_map (fn ($ d ) => new Document ($ d ), $ data );
413+
414+ $ results = [];
415+ $ count = $ database ->createDocuments (__FUNCTION__ , $ documents , onNext: function ($ doc ) use (&$ results ) {
416+ $ results [] = $ doc ;
417+ });
418+
419+ $ this ->assertEquals ($ count , \count ($ results ));
420+ $ this ->assertEquals (10 , \count ($ results ));
421+
422+ /**
423+ * Update 1 row
424+ */
425+ $ data [\array_key_last ($ data )]['number ' ] = 100 ;
426+
427+ /**
428+ * Add 1 row
429+ */
430+ $ data [] = [
431+ '$id ' => "101 " ,
432+ 'number ' => 101 ,
433+ ];
434+
435+ $ documents = array_map (fn ($ d ) => new Document ($ d ), $ data );
436+
437+ Authorization::disable ();
438+
439+ $ results = [];
440+ $ count = $ database ->createOrUpdateDocuments (
441+ __FUNCTION__ ,
442+ $ documents ,
443+ onNext: function ($ doc ) use (&$ results ) {
444+ $ results [] = $ doc ;
445+ }
446+ );
447+
448+ Authorization::reset ();
449+
450+ $ this ->assertEquals (2 , \count ($ results ));
451+ $ this ->assertEquals (2 , $ count );
452+ }
453+
454+ public function testUpsertDocuments (): void
392455 {
393456 /** @var Database $database */
394457 $ database = static ::getDatabase ();
0 commit comments