Skip to content

Commit fbff545

Browse files
committed
test: update tests to new full sync
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 08eea0e commit fbff545

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
66
* SPDX-License-Identifier: AGPL-3.0-only
77
*/
8+
89
namespace OCA\DAV\Tests\unit\CardDAV;
910

1011
use GuzzleHttp\Exception\ClientException;
@@ -297,10 +298,26 @@ public function testSyncWithDeletedElement(): void {
297298
}
298299

299300
public function testFullSyncWithOrphanElement(): void {
301+
$pendingCards = [];
300302
$this->backend->expects($this->exactly(0))
301303
->method('createCard');
302304
$this->backend->expects($this->exactly(1))
303-
->method('updateCard');
305+
->method('updateCard')
306+
->willReturnCallback(function ($id, $uri) use (&$pendingCards) {
307+
unset($pendingCards[$uri]);
308+
});
309+
$this->backend->expects($this->exactly(1))
310+
->method('markCardsAsPending')
311+
->willReturnCallback(function ($id) use (&$pendingCards) {
312+
$cards = array_values($this->backend->getCards($id));
313+
$uris = array_map(fn ($card) => $card['uri'], $cards);
314+
$pendingCards = array_combine($uris, $cards);
315+
});
316+
$this->backend->expects($this->exactly(1))
317+
->method('getPendingCards')
318+
->willReturnCallback(function ($id) use (&$pendingCards) {
319+
return array_values($pendingCards);
320+
});
304321
$this->backend->expects($this->exactly(1))
305322
->method('deleteCard');
306323

@@ -355,6 +372,7 @@ public function testFullSyncWithOrphanElement(): void {
355372
['uri' => 'Database:bob.vcf'],
356373
]);
357374

375+
$this->service->markCardsAsPending(1);
358376
$token = $this->service->syncRemoteAddressBook(
359377
'',
360378
'system',
@@ -365,6 +383,7 @@ public function testFullSyncWithOrphanElement(): void {
365383
'principals/system/system',
366384
[]
367385
)[0];
386+
$this->service->deletePendingCards(1);
368387

369388
$this->assertEquals('http://sabre.io/ns/sync/3', $token);
370389
}

0 commit comments

Comments
 (0)