@@ -297,10 +297,26 @@ public function testSyncWithDeletedElement(): void {
297297 }
298298
299299 public function testFullSyncWithOrphanElement (): void {
300+ $ pendingCards = [];
300301 $ this ->backend ->expects ($ this ->exactly (0 ))
301302 ->method ('createCard ' );
302303 $ this ->backend ->expects ($ this ->exactly (1 ))
303- ->method ('updateCard ' );
304+ ->method ('updateCard ' )
305+ ->willReturnCallback (function ($ id , $ uri ) use (&$ pendingCards ) {
306+ unset($ pendingCards [$ uri ]);
307+ });
308+ $ this ->backend ->expects ($ this ->exactly (1 ))
309+ ->method ('markCardsAsPending ' )
310+ ->willReturnCallback (function ($ id ) use (&$ pendingCards ) {
311+ $ cards = array_values ($ this ->backend ->getCards ($ id ));
312+ $ uris = array_map (fn ($ card ) => $ card ['uri ' ], $ cards );
313+ $ pendingCards = array_combine ($ uris , $ cards );
314+ });
315+ $ this ->backend ->expects ($ this ->exactly (1 ))
316+ ->method ('getPendingCards ' )
317+ ->willReturnCallback (function ($ id ) use (&$ pendingCards ) {
318+ return array_values ($ pendingCards );
319+ });
304320 $ this ->backend ->expects ($ this ->exactly (1 ))
305321 ->method ('deleteCard ' );
306322
@@ -355,6 +371,7 @@ public function testFullSyncWithOrphanElement(): void {
355371 ['uri ' => 'Database:bob.vcf ' ],
356372 ]);
357373
374+ $ this ->service ->markCardsAsPending (1 );
358375 $ token = $ this ->service ->syncRemoteAddressBook (
359376 '' ,
360377 'system ' ,
@@ -365,6 +382,7 @@ public function testFullSyncWithOrphanElement(): void {
365382 'principals/system/system ' ,
366383 []
367384 )[0 ];
385+ $ this ->service ->deletePendingCards (1 );
368386
369387 $ this ->assertEquals ('http://sabre.io/ns/sync/3 ' , $ token );
370388 }
0 commit comments