test: update tests to new full sync

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-04-07 17:59:52 +02:00
parent e87645a78a
commit e164139c57
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB

View file

@ -5,6 +5,7 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\DAV\Tests\unit\CardDAV;
use GuzzleHttp\Exception\ClientException;
@ -293,10 +294,26 @@ END:VCARD';
}
public function testFullSyncWithOrphanElement(): void {
$pendingCards = [];
$this->backend->expects($this->exactly(0))
->method('createCard');
$this->backend->expects($this->exactly(1))
->method('updateCard');
->method('updateCard')
->willReturnCallback(function ($id, $uri) use (&$pendingCards) {
unset($pendingCards[$uri]);
});
$this->backend->expects($this->exactly(1))
->method('markCardsAsPending')
->willReturnCallback(function ($id) use (&$pendingCards) {
$cards = array_values($this->backend->getCards($id));
$uris = array_map(fn ($card) => $card['uri'], $cards);
$pendingCards = array_combine($uris, $cards);
});
$this->backend->expects($this->exactly(1))
->method('getPendingCards')
->willReturnCallback(function ($id) use (&$pendingCards) {
return array_values($pendingCards);
});
$this->backend->expects($this->exactly(1))
->method('deleteCard');
@ -351,6 +368,7 @@ END:VCARD';
['uri' => 'Database:bob.vcf'],
]);
$this->service->markCardsAsPending(1);
$token = $this->service->syncRemoteAddressBook(
'',
'system',
@ -361,6 +379,7 @@ END:VCARD';
'principals/system/system',
[]
)[0];
$this->service->deletePendingCards(1);
$this->assertEquals('http://sabre.io/ns/sync/3', $token);
}