Skip to content

Commit 68901dd

Browse files
committed
test: update tests to new full sync
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 41df537 commit 68901dd

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

apps/dav/tests/unit/CardDAV/SyncServiceTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)